www.webdeveloper.com
Results 1 to 3 of 3

Thread: on ul li how not to fire click babble on children

  1. #1
    Join Date
    May 2014
    Posts
    13

    on ul li how not to fire click babble on children

    on ul li how not to fire click on children..
    how to make each tag independent from babbling down events?

    http://jsfiddle.net/mHP7a/1/
    thanks

  2. #2
    Join Date
    Sep 2007
    Posts
    317
    If I understand
    Code:
    $('.dropdown').click(function (event) { 
        //alert(event.target.getAttribute('class'));
        if(event.target.getAttribute('class')=='dropdown') { alert('click on dropdown'); } 
    });
    This code is working on Firefox 4.0b9
    Last edited by Ayşe; 06-26-2014 at 06:46 PM.

  3. #3
    1) I assume you mean bubbling.

    2) The bubble order is child to parent, not the other way around...

    Ayşe has it right that you're pretty much going to have to check it by class. Either that or you could add a child like a span for the text content, and target just that instead of the parent tag that wraps everything.

    *** SIDE NOTE *** all those data attributes in a dropdown is... well, making me suspicious you're using JS for nothing.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles