开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜