I am using jQuery and put this code in my javascript:
function HideMe(itemID) {
var myDiv = \'item_\' + itemID;
$(myDiv).fadeOut(\"slow\");
}
It looks like jquery is not correctly attached to the page.
Check your linking to jQuery.
It happened to me because of slim version of Jquery library. Full version of Jquery library includes animation.
Jquery CDN available at https://code.jquery.com/
Try keeping it inside
$(document).ready(function(){
// your code. and don't forget the '#' in front of item.
});
Looks like you're trying to call the function before jQuery / the DOM loads.
I had this error because I was using a slim version of jQuery. If you download the full version you should be okay.
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.
Also, you probably forgot a #
in the selector (unless you've got something like <item_1 />
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.