如何检查下一个元素的类型?

如何检查下一个元素的类型?

问题描述:

我如何检查id ="id"之后的元素是段落?

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')){}

.next() .is() 方法将以一种可读的方式做到这一点:

A chain of .next() and .is() methods would do it in a readable way:

if($('#id').next().is('p')) {
    // it's a paragraph
}