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

后端 未结 10 849
感情败类
感情败类 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:31

    Also, you probably forgot a # in the selector (unless you've got something like in the markup).

    var myDiv = '#item_' + itemID;
    

    jQuery uses CSS selectors to search for elements, so without the #, you'd get every element with the tag item_x instead of the ID.

提交回复
热议问题