开发者

Open a div at place clicked

I have a rather simple question but i can't seem to fin开发者_高级运维d 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜