user3530755
user3530755

Reputation:

How to remove bubbling effect in jQuery?

I am making a demo in which I have one row above which I have flip button .I want alert will display only when user click on row. But some time it display alert when user click on flip button? http://jsfiddle.net/9mLEj/9/

$(document).ready(function(){

    $('#rowClick').click(function(){
     alert('--')   
    })


})

Upvotes: 1

Views: 163

Answers (1)

Felix
Felix

Reputation: 38102

You can use e.stopPropagation() to prevent event bubble up the DOM tree:

$(document).ready(function () {
    $('#rowClick').click(function () {
        alert('--')
    })

    $('#sliderClick').click(function (e) {
        e.stopPropagation();
    })
})

Updated Fiddle


Seem like jQuery mobile has changed the structure of your HTML markup, try this:

$(document).ready(function () {
    $('#rowClick').click(function () {
        alert('--')
    })

    $('#rowClick .ui-slider').click(function (e) {
        e.stopPropagation();
    })
})

Updated Fiddle

Upvotes: 1

Related Questions