get the data-attribute using closest returning null

jquery

Solution

You need to use `.siblings` instead of `.closest`

$(".DivImgEdit").click(function(){
     alert($(this).siblings('.DivImgRun').data('internalid'));
});

closest look's among parents, in your case, the desired element is sibling and not the parent

Demo `--->` http://jsfiddle.net/Rpazu/2/

Problem

I have some set of `div` which are having `class(es)` based on its functionalities, from that, I just tried to get the `data attribute` of the `first div` from the `last div`. So that, I decided that `closest` will suits my requirement. but unfortunately it is returning `null`. Can anybody tell me what is wrong with my snippet. HTML: ``` <div class="DivApplication"> <div class="DivImg DivImgRun DivImgLeft" data-internalid=16></div> <div class="DivAppName">Application Title</div> <div class="DivTime">Created: 23-06-2013 | Edited: 23 July 2013 </div> <div class="DivImg DivImgReport DivImgRight">report</div> <div class="DivImg DivImgDelete DivImgRight">delete</div> <div class="DivImg DivImgEdit DivImgRight">edit</div> </div> ``` JQUERY: ``` $(document).ready(function(){ $(".DivImgEdit").click(function(){ alert($(this).closest('.DivImgRun').data('internalid')); }); }); ``` RESULT: `NULL` DEMO

Original source