为什么jQuery不能在我的网站上运行? [重复]

Possible Duplicate:
jQuery not even being called

Funny thing is, on jsfiddle it works perfectly if I select the latest jQuery option from the left panel. The website is basically a test page to run this menu function. HTML:

 <script src="http://code.jquery.com/jquery.min.js"></script>
<script>
  $('a.expand').hover(function() {
  $('#Menu').slideToggle();
});



</script>
<a href="" class="expand">
<p>hello!</p>
</a>
<div id="Menu">
wowtest
</div>

It's a PHP file if that helps.

jsfiddle: http://jsfiddle.net/txeD9/

That's because there is no a.expand element when you execute the script, as the elements are declared after.

Put your code at end of the body or use a ready callback by changing it to

<script>
   $(function(){
    $('a.expand').hover(function() {
      $('#Menu').slideToggle();
    });
   });
</script>

Writing $(function(){ somecode }); asks jQuery to execute somecode when the DOM is ready.