Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery length of attribute undefined

Tags:

jquery

attr

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

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

like image 919
qba Avatar asked Dec 21 '22 20:12

qba


1 Answers

Your spelling is just a bit off, .lenght should be .length:

var action = $(obj).closest("form").attr('action');
alert(action.length);
like image 116
Nick Craver Avatar answered Dec 28 '22 08:12

Nick Craver