テーブル onclick のセルからこの関数に行が渡される JavaScript 関数 (関数 toggleTree(theRow) ) があります。
<tr class="rowWhite"><td style="text-align:center"><img class="expand" alt="" src="images/plus.jpg"onclick="toggleTree(this.parentNode.parentNode);" />
トグルツリー機能は以下です。
function toggleTree(theRow)
{
var imgEl = theRow.cells[0].firstChild;
if (theRow.cells[0].firstChild.className == "expand")
{
theRow.cells[0].firstChild.className="collapse";
theRow.cells[0].firstChild.src="images/minus.jpg";
alert(theRow.cells[0].firstChild.className);
alert(theRow.cells[0].firstChild.src);
return "expand";
}
else
{
theRow.cells[0].firstChild.className="expand";
theRow.cells[0].firstChild.src="images/plus.jpg";
alert(theRow.cells[0].firstChild.className);
alert(theRow.cells[0].firstChild.src);
return "collapse";
}
}
theRow.cells[0].firstChild.className と theRow.cells[0].firstChild.src の値が IE と Firefox で異なるため、関数は FF では機能しませんが、IE では機能します。任意のブラウザから値を jsfunction に取得するにはどうすればよいですか?