Clicking in layered DIV elements RRS feed

  • Question

  • User1513526840 posted

    I have a calendar application that has DIV elements to divide the days of the week, then DIV elements contained within to represent events that occur during each day. I am calling doPostback on a click in each of these DIVs. I figured out to set the z-order so the click comes through for the right DIV but now I get an event fired for the window on top and the one below. Is there a way to get the mouse click event to only fire for the top most DIV?

    Thursday, July 15, 2010 3:18 PM


  • User-861155893 posted

    This happens because of event bubbling

    In the Microsoft model you must set the event’s cancelBubble property to true.

    window.event.cancelBubble = true

    In the W3C model you must call the event’s stopPropagation() method.


    read http://www.quirksmode.org/js/events_order.html (about 3/4 of the way down)
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 15, 2010 4:21 PM