This is very similar to this question, but it's not working for me. I've also looked at this and this, but still not working.
I need to get the table ID above the clicked button.
If I click the top button (remove request div) I would get table t1 ID.
My code looks like this:
<table id="t1"></table>
<div class="bulk_action">
<div title="Remove requests" class="trash_iconset_grey_16px removeRequest"></div>
<div title="some other button" class="abc"></div>
</div>
<table id="t2"></table>
<div class="bulk_action">
<div title="Remove requests" class="trash_iconset_grey_16px removeRequest"></div>
<div title="some other button" class="abc"></div>
</div>
JS code
jQuery('.removeRequest').live ('click', function(){
var div_obj = jQuery(this).closest('div');
//alert(jQuery(div_obj).attr('class')); //<-- this works
var tbl = jQuery(div_obj).prev('table:first'); // <-- This is not working
alert(jQuery(tbl).attr('id'));
});
Does anyone have any tips on how to solve this?