Why does jQuery throw the error `fadeOut is not a function'?

后端 未结 10 737
感情败类
感情败类 2020-12-01 17:59

I am using jQuery and put this code in my javascript:

function HideMe(itemID) {
    var myDiv = \'item_\' + itemID;
    $(myDiv).fadeOut(\"slow\");
}
         


        
10条回答
  •  有刺的猬
    2020-12-01 18:27

    Even if the selector didn't return any items in the collection the function call would have worked (not generated this error anyway) if jQuery was loaded correctly. Either there is a conflict in the page, or it didn't load at all. You can try

    jQuery(myDiv).fadeOut("slow");
    

    or look into why jQuery hasn't been loaded.

    P.S.: don't forget the # in the selector if selecting by id.

提交回复
热议问题