JQuery attribute length undefined

How can I check the length of the string that is in the attribute? This shows the value undefined:

var action = $(obj).closest("form").attr('action');
alert(action.lenght);

+3
source share
2 answers

Your spelling is just a bit, .lenghtshould be .length:

var action = $(obj).closest("form").attr('action');
alert(action.length);
+10
source

Always go to the api when no method is found before you make a message somewhere.

http://api.jquery.com

http://api.jquery.com/length/

0
source

Source: https://habr.com/ru/post/1778947/


All Articles