i have two tag, which has same class but different trigger events, following is example:
<a class="remove">remove this</a>
<div class="status"><a class="remove">Remove this status div only</a></div>
in jquery i have it like
$(".remove").live('click', function()... (this gets trigger for both)
$(".status_update > .remove").live('click', function()... (i want this to trigger for status div remove link)
开发者_高级运维i need to do this in two different triggers, cant do it in same trigger call.
Try this
$(".remove").live('click', function() {
if ($(this).parent().hasClass('status_update')) // execute inner links code
else // execute outer links code
});
You can test if the clicked anchor's parent's class name is .status
and act accordingly, using either .unwrap
or .remove
:
$("a.remove").live('click', function() {
if($(this).parent().hasClass("status")) { // or $(this).parent('.status').length
$(this).unwrap("div.status");
} else {
$(this).remove();
}
});
精彩评论