Hello, I have a rather simple question but i can't seem to find an answer to it. I want when i click on any place on web page a div is opened. how can i accomplish that CSS style. My question is about the position of the div if i add this div inside a table and i want it to be opened each time i click on different rows. Thanks.
A:
Hmmm try something like this:
<table>
<tr onclick="d=document.getElementById('myDiv');if(d.style.display=='block'){d.style.display='none';}else{d.style.display='block';}">
<td><td>
</tr>
<tr onclick="d=document.getElementById('myDiv');if(d.style.display=='block'){d.style.display='none';}else{d.style.display='block';}">
<td><td>
</tr>
</table>
<div id="myDiv" style="display:none">
STuff
</div>
There are better ways to do this.. Im not sure if the tr tag has an onclick handler but its worth a try. You could use a javascript library like jquery or mootools.
Ali
2010-06-13 09:47:04
i'm attempted to downvote this, but i hate downvoters! ;)
aSeptik
2010-06-13 09:51:49