Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
127
rated 0 times [  132] [ 5]  / answers: 1 / hits: 23696  / 10 Years ago, fri, august 8, 2014, 12:00:00

I am trying to make a div disappear with javascript. It just doesn't work. What am I doing wrong?



<script src=//code.jquery.com/jquery-1.11.0.min.js></script>
<script type=text/javascript>
document.getElementById(des).style.visibility = hidden;
</script>

<div id=des>
Text.
<a href=>link</a>
</div>

More From » jquery

 Answers
4

You are running the script before the DOM has loaded.



If you put the script after the div, it works


[#69853] Wednesday, August 6, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jennie

Total Points: 593
Total Questions: 102
Total Answers: 106

Location: Federated States of Micronesia
Member since Fri, Sep 16, 2022
2 Years ago
jennie questions
;