$ is not a function - jQuery error

前端 未结 10 1188
余生分开走
余生分开走 2020-11-29 20:41

I have the jQuery loaded fine, I\'ve quadruple-checked, though I\'m getting this error in FireBug \"$ is not a function\" and my code doesn\'t work.

Here\'s my code:

10条回答
  •  孤独总比滥情好
    2020-11-29 20:58

    When jQuery is not present you get $ is undefined and not your message.

    Did you check if you don't have a variable called $ somewhere before your code?
    Inspect the value of $ in firebug to see what it is.

    Slightly out of the question, but I can't resist to write a shorter code to your class assignment:

        var i = 1;
        $("ol li").each(function(){
            $(this).addClass('olli' + i++);
        });
    

提交回复
热议问题