Skip to content

Instantly share code, notes, and snippets.

@DasLampe
Created October 10, 2011 15:47
Show Gist options
  • Save DasLampe/1275652 to your computer and use it in GitHub Desktop.
Save DasLampe/1275652 to your computer and use it in GitHub Desktop.
JQuery select block before current main block
/**HTML CODE
<div class="edit_content_options"><a class="edit_link">Edit</a></div>
<div>
<div>Edit block, with event</div>
</div>*/
function find_parent(current_block)
{
var parent, searchblock, edit_option;
parent = current_block.parent();
searchblock = parent.find('div[class="edit_content_options"]');
if(searchblock.length == 0)
{
return find_parent(parent);
}
else
{
edit_option = current_block.prev();
return edit_option.find('a[class="edit_link"]').attr('href');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment