[Solved] Javascript: How can this code be reduced or improved?


Using a single function that is called with the elements as parameters

var directorOneText = document.getElementById('directorOneText');
var directorTwoText = document.getElementById('directorTwoText');

function changeText(t1, t2) {
    t1.style.display = (t1.style.display === "block") ? "none" : "block";
    t2.style.display = "none";
}

var directorOneClickEvent = document.getElementById('directorOne').addEventListener("click", function(){ changeText(directorOneText, directorTwoText)});
var directorTwoClickEvent = document.getElementById('directorTwo').addEventListener("click", function(){ changeText(directorTwoText, directorOneText)});
#directorOne {background:#333; padding: 20px;}
#directorTwo {background:#ddd; padding: 20px;}
<div id="directorOne">d1<textarea id="directorOneText"></textarea></div>
<div id="directorTwo">d2<textarea id="directorTwoText"></textarea></div>

solved Javascript: How can this code be reduced or improved?