I am trying to get this to alert only the div clicked on, vs alerting the div clicked and then the container div's. when I click on the third div I would like it to only alert "third". thanks for the help.
<div id="first">   
    <div id="second">
        <div id="third">
            third div
        </div>
        second div
    </div>
    first div
</div>
$("div").click(function() {
    alert(this.id);
});
                $("div").click(function(e) {
    alert(this.id);
    e.stopPropagation();
})
that will do it.
event.stopPropagation();
$("div").click(function(event) {
    alert(this.id);
    event.stopPropagation();
})
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With