0
JQuery - attr is not a function
I have face this issue during my endeavour. Solved it by using the syntax <element>[<attribute>] instead. A search online indicates that the attr() only works on pure JQuery objects; those wrap in $(<selector>). Is this true and is this the case for other jQuery method as well , e.g. html(), CSS() ?
1 Answer
+ 1
Yes, you are right.
Firstly, you can find element by selector or create new element and then can use methods like attr, css, show, hide, data, addClass, on, etc. For example:
$(".my-link").addClass("big").show();
But some methods you can use without html element, e.g. $.each(...), $.ajax(...)