I'm trying to get value from an HTML list
& lt; Div id = "test" & gt; & Lt; Ul & gt; & Lt; Li & gt; C: \ & lt; Ul class = "leftbutton" & gt; & Lt; Li value = "list1" & gt; Folder 1 & lt; / Li & gt; & Lt; Li value = "list2" & gt; Folder 2 & lt; / Li & gt; & Lt; Li value = "list3" & gt; Folder 3 & lt; / Li & gt; & Lt; Li value = "list4" & gt; Folder 4 & lt; / Li & gt; & Lt; Li value = "list5" & gt; Folder 5 & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; I used the following code
$ ("# test li"). Live ('click', function) {alert ($ (this text ());}); If I click on List 1, Warning Now my problem is that I need to get a warning C: \ Folder 1 if I click on List1 and C: \ Folder 3 if I click on List 3
< Strong> Edit: I'm showing here that there is a directory structure tree view. There will be more levels because more sub The folders update HTML code can be shown below
gt; & lt; duration & Gt; C: \ & lt; / span & gt; & lt; ul class = "leftbutton">
The easiest solution is to wrap a "C": \ รข ??? ? & lt; Span & gt; In this way: & lt; Div id = "test" & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Period & gt; C: \ & lt; / Span & gt; & Lt; Ul class = "leftbutton" & gt; & Lt; Li value = "list1" & gt; Folder 1 & lt; / Li & gt; & Lt; Li value = "list2" & gt; Folder 2 & lt; / Li & gt; & Lt; Li value = "list3" & gt; Folder 3 & lt; / Li & gt; & Lt; Li value = "list4" & gt; Folder 4 & lt; / Li & gt; & Lt; Li value = "list5" & gt; Folder 5 & lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt; Then, in jQuery:
$ ('# test li li'). Live ('click', function (event) {var $ this = $ (This); Warning ($$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ / Code> or E: \ . . P> Demo:
Comments
Post a Comment