Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  97] [ 5]  / answers: 1 / hits: 50197  / 14 Years ago, sun, december 5, 2010, 12:00:00

I'm trying to do this without Jquery. I want to show a div when clicking a trigger. So far I have this to hide the element.



 document.getElementById('element').style.display = 'none';


HTML..



<div class=element>Ahem, boo!!</div>
<a href=# id=showDiv>Show</a>


How do I create a function to show the div when clicking the link? I would like to avoid using functions like onclick=showDiv() in the link itself.


More From » html

 Answers
3
document.getElementById('showDiv').onclick=function(){
// Remove any element-specific value, falling back to stylesheets
document.getElementById('element').style.display='';
};

[#94724] Friday, December 3, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stacyl

Total Points: 131
Total Questions: 105
Total Answers: 94

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago
stacyl questions
Thu, Jan 28, 21, 00:00, 3 Years ago
Sun, Mar 8, 20, 00:00, 4 Years ago
Tue, Feb 25, 20, 00:00, 4 Years ago
Tue, Feb 11, 20, 00:00, 4 Years ago
;