I have jQuery code like:
$(this).next().next().next().next().html('<span>anything</span>');
Now I want to know if there is an alternative for these functions .next()? (something like 4*next())
Note: .nextUntil() it doesn’t suit me because I don’t have a clue to use it in .nextUntil(). (My HTML structure is dynamic, in other words, it is not constant. Sometimes the final element is span, and sometimes it div, etc.)
Edit: Here are some examples for my HTML structure:
example1:
<button>click it</button>
<div>div1</div>
<div>div2</div>
<span>span1</span>
<a>a1</a>
<div>div3</div>
example2:
<button>click it</button>
<span>span1</span>
<b>b1</b>
<span>span2</span>
<div>div1</div>
<div>div2</div>
<div>div3</div>
source
share