HTML Code:
<div id="1" class="master"></div>
<div id="2" class="slave"></div>
<div id="3" class="slave"></div>
<div id="4" class="master"></div>
<div id="5" class="slave"></div>
<div id="6" class="slave"></div>
let's say, we use $('div').click() to make these DIV elements clickable:
$('div').click(function() {
var el = $(this);
var master_id = ???;
alert(master_id);
});
Then, clicking on DIV elements with class "slave" we need to alert the ID of the closest upper DIV element with class "master", so, if we click on DIV#5 or DIV#6, alerts = "4" (DIV#4), if DIV#2 or DIV#3 - alerts = "1" (DIV#1). But how to do that? ;)