$ is not a function – jQuery error

<script type="text/javascript">
    $("ol li:nth-child(1)").hide()
</script>

在  WordPress 上寫 javascript jQuery, 會錯,發現原來是 jQuery 會衝到,要多一個框框給jQuery:

In WordPress jQuery.noConflict() is called on the jQuery file it includes (scroll to the bottom of the file it’s including for jQuery to see this), which means $ doesn’t work, but jQuery does, so your code should look like this:

<script type="text/javascript">
  jQuery(function($) {
    for(var i=0; i <= 20; i++) 
      $("ol li:nth-child(" + i + ")").addClass('olli' + i);
  });
</script>

from: http://stackoverflow.com/questions/3931529/is-not-a-function-jquery-error

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *