How can I check the type of the next element?
How can i check that element after id="id" is paragraph?
<div>
<p id="id">one</p>
<p>two</p开发者_运维问答>
</div>
I want something like this, but working.
if ($("#id").next() == $('p')){}
A chain of .next()
and .is()
methods would do it in a readable way:
if($('#id').next().is('p')) {
// it's a paragraph
}
use standard nodeName property
if ($("#id").next().get(0).nodeName == 'P')
get(0) construct returns the underlying DOM element of the JQuery object
精彩评论