javascript - how to get the next image tag after specific dom tag, sibling or not? -


let's code such as

<html> <h1>heading</h1> <div>   <div>       <span>             <img src="source"/>        </span>   </div> </div>  </html> 

the above example, should work html code.

need next image tag after <h1> no matter img placed
$('h1').nextall('img').first() or $('h1').nextuntil('img').last().next() won't work here because not siblings of <h1>. there way can img without writing loop code?

var $h1 = $("h1"); // `h1` var = $("*"); // dom elements  var h1idx = all.index($h1); all.splice(0, h1idx); // rid of before , until `h1`  var result = all.filter("img").first(); // first `img` 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -