javascriptjqueryjquery-selectorssiblings

jQuery.next() returns empty object


I'm trying to get the next div after an image:

<a rel="nofollow" href="http://localhost:8046/file.htm" class="imgbox">
    <img src="http://www.domain.tld/fm/912/image.png" class="" id="img-1303122" style="max-width:560px;" width="700" border="0" alt="title="/>
</a>
<div id="lic-img-1303122" class="licence-wrapper" style="display:none;">
    <div class="licence-spacer"></div>
    <div class="licence">&copy; copyright<br /></div>
</div>

My jQuery code is the following:

console.log($("#img-1303122").nextAll(".licence-wrapper"));
Object { length: 0, prevObject: Object, context: HTMLDocument → JSUmstellung, selector: "#img-1303122.nextAll(.licence-wrapper)" }

So, why do I get no result? I already tried .next(), .closest() and .siblings() and none of them worked.


Solution

  • try :-

    console.log($("#img-1303122").parent().nextAll(".licence-wrapper"));
    

    Demo