I having trouble to select the currently clicked container element.
My Html
<div class="cparent">
foo1
<a href="javascript:void(0);" class="delete">Delete</a>
</div>
<div class="cparent">
foo2
<a href="javascript:void(0);" class="delete">Delete</a>
</div>
I mean when I click on delete link, corresponding container should disappear. How can I do this?
What I tried !
$(".cparent",this).html('Deleting...').delay(1000).fadeOut();// not working
My script
$(".delete").live("click",function(){
var cur = $(".delete").index(this);
$(".cparent").eq(cur).html('Deleting...').delay(1000).fadeOut();
});
Above one is also not working. Have a look at this Example for clarification.
Use the
parent[API Ref] method:Passing
thisas the second parameter to the jQuery function won’t find elements that are abovethis. Alternatively, you can use theclosest[API Ref] method: