jQuery click on li with nested ul -
I have a list within the lists when a user searches for a list item (
& lt; Ul & gt;
Before adding to the nested lists I wanted to show that, when I click on a list item, there would be any function, now, clicking on any of the nested lists, that function also is run. That makes sense, because they are part of the list item.
A "bucket" & gt; & Lt; Li class = "bucket" & gt; & Lt; Img src = "arrow_group_collapsed_true.png" square = "arrow" & gt; & Lt; Img src = "blue_folder.png" category = "folder" & gt; See all & lt; / Li & gt; & Lt; Li class = "bucket" & gt; & Lt; Img src = "arrow_group_collapsed_false.png" square = "arrow" & gt; & Lt; Img src = "blue_folder.png" category = "folder" & gt; Group & lt; Ul style = "display: block;" & Gt; & Lt; Li id = "group_id_15036" class = "group_bucket" & gt; & Lt; Img src = "arrow_group_collapsed_true.png" square = "arrow" & gt; & Lt; Img src = "blue_folder.png" category = "folder" & gt; Group 1 & lt; / Li & gt; & Lt; Li id = "group_id_14910" class = "group_bucket" & gt; & Lt; Img src = "arrow_group_collapsed_true.png" square = "arrow" & gt; & Lt; Img src = "blue_folder.png" category = "folder" & gt; Group 2 & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; Javascript (not much about it, I can show more than I need): I want to click on "group" or "see all" to run the click function, but "group 1 "Should not be a click or" group 2 " around the first part of the list item and lt; Span & gt; Apart from wrapping it, the ceremony is going on, there is a selector who runs something on my parents <
& lt; Ul class =>
$ ('li.bucket') .live (' Click ', function () {// do stuff})
There is an official way, but in your case, it may possibly be expensive:
$ ('li.bucket *'). Live ('click', function (event) {event.stopPropagation ()}); Children of
li
will now have a handler that prevents the event from moving upward and triggers the handler of li
Please try it out and see if the application is not very slow.
Comments
Post a Comment