JQuery - add click event to LI or SPAN elements?

前端 未结 4 1481
名媛妹妹
名媛妹妹 2021-02-08 23:00

I am trying to add a click event to a LI element but it is not firing in the page. My page markup looks like:

4条回答
  •  广开言路
    2021-02-08 23:43

    I did the same thing as @Parrots and it works for me. You might, however, want to change your selector to:

    $("#Navigation li[title]" ).live('click', function(e) {
         e.preventDefault;
         this.blur();
         return updateNavigation($(this).attr('title'));
    });
    

    So that the handler is only applied to elements that have a title attribute.

提交回复
热议问题