Well, you are launching into an area where we become dependant upon your markup following what you have outlined above. That is, with a td following a td, the second one containing the 'showstate' span. As long as you follow that formula, this will work. Add this function to the script, it can go at the end, just above the </script> tag:
Code:
function findNextCell(obj){
returnobj=obj.nextSibling;
while(typeof returnobj.tagName=='undefined'||returnobj.tagName.toLowerCase()!=='td')
if(returnobj.nextSibling)
returnobj=returnobj.nextSibling
else {
alert('markup error')
return;
}
return returnobj;
}
Once that is installed, you can use this syntax in the HTML part:
Code:
<td onClick="expandcontent(findNextCell(this), 'sc1')" style="cursor:hand; cursor:pointer">Menu</td>
<td onClick="expandcontent(this, 'sc1')" style="cursor:hand; cursor:pointer"><span class="showstate"></span></td>
If you goof up, it will let you know. You also can still use the original syntax wherever that applies, as in the second td or if you wish to have something like this:
Code:
<h3 onClick="expandcontent(this, 'sc2')" style="cursor:hand; cursor:pointer"><span class="showstate"></span>Difference betwen Java & JavaScript?</h3>
elsewhere on the page.
Bookmarks