Tuesday 17 September 2013

JS: How to get two IDs

JS: How to get two IDs

This won't work:
<a onclick="if(document.getElementById('div2','div1')
.style.display=='none') {document.getElementById('div2','div1')
.style.display=''}else
{document.getElementById('div2','div1') .style.display='none'}">
this1 ~~
</a>
<div id="div1" style="display:none">
1
</div>
<a onclick="if(document.getElementById('div2') .style.display=='none')
{document.getElementById('div2') .style.display=''}else
{document.getElementById('div2') .style.display='none'}">
this2 ~~
</a>
<div id="div2" style="display:none">
2
</div>
How do I show div2 and div1 when I click on this1~~? It only shows div2 on
click instead of showing both. Why isn't it working?

No comments:

Post a Comment