开发者

element.nodeName not defined for a html element created using jQuery

开发者 https://www.devze.com 2023-01-01 11:05 出处:网络
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,

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消