Monday, June 6, 2011

Getting nodeName from jQuery

Below method won't work
$('.myClass').nodeName;  // it will return undefined

The reason is you are calling a "property" that is not existing in the jquery object.

...

The correct way to do this is
$('.myClass').get(0).nodeName;

or

$('.myClass')[0].nodeName;


No comments:

Post a Comment