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() ?

20th Mar 2020, 1:09 PM
Derrick
Derrick - avatar
1 Respuesta
+ 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(...)
31st Mar 2020, 1:45 AM
Hello World
Hello World - avatar