views:

25

answers:

1

I have the following line of code:

<li id="1" class=" ">
<a href="">Parking Lot</a>
<span id="1" class="list-edit">edit</span>
</li>

I then have two binds:

$("#lists li").click(function(){.......

$(".list-edit").click(function(){.........

The problem I'm having is I need the LI to contain the EDIT span because of CSS styling reasons, I have a big blue background. But this is preventing me from binding the EDIT btn. Is there a way to get these two to play nice?

Thxs

+1  A: 

You can use event.stopPropagation to prevent the click handler attached to the parent LI from firing when the edit span is clicked (if that's what you mean):

$(".list-edit").click(function(e){
    e.stopPropagation();
    // do stuff
});
karim79
Awesome - I love learning something new - thank you
AnApprentice
Turns out this doesn't work... It's still catching both of the binds.
AnApprentice
@nobosh - are you passing the event object through the callback? i.e. `$(".list-edit").click(function(e){`
karim79