Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

why is my toggle function working on this jsfiddle but not my site?

Here is the JS Fiddle: http://jsfiddle.net/timur/bMfdD/4/ Here is the website: http://www.blindsdetroit.com/testing

<a id="clickMe" href="#">Type of Worker</a>

<div id="clickEvent" class="hide">
<ul>
<li>Rivermen</li>
<li>Boatmen</li>
<li>stuff</li>
</ul>    
</div>

Here is the jquery

$('#clickMe').click(function() {
$("#clickEvent").fadeToggle("slow");
});

here is the css

.hide  { display:none; }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
151 views
Welcome To Ask or Share your Answers For Others

1 Answer

Wrap your code in .ready() so that it will run once the DOM is loaded

$(document).ready(function(){
  $('#clickMe').click(function() {
     $("#clickEvent").fadeToggle("slow");
  });
});

or put your JS file before body ends


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...