element.nodeName not defined for a html element created using jQuery
I created a new HTML element using jQuery.
var v=jQuery('<p>Hello</p>);
But when I try to get the nodeName of the new element,
v.nodeName.toLowerCase();
I get error, saying that nodeName 开发者_Go百科is not defined. What is wrong here?
Thanks.
v
is the jQuery object that contains the dom element not the real dom element, you must do:
v[0].nodeName.toLowerCase();
精彩评论