Note that there are some explanatory texts on larger screens.

plurals
  1. POget text of a list on click using jquery
    primarykey
    data
    text
    <p>I am trying to get value from an HTML list</p> <pre><code>&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; </code></pre> <p>i used the following code </p> <pre><code> $("#test li").live('click', function (event) { alert($(this).text()); }); </code></pre> <p>i get the alert as Folder 1 if i clicked the list1 Now my problem is that i need to get the alert as C:\Folder 1 if i click the List1 and C:\Folder 3 if i click list3</p> <p><strong>EDIT:</strong> I am showing here is a directory structure treeview. there will be more levels as there can be more sub folders updated html code shown below</p> <pre><code>&lt;div id="test"&gt; &lt;ul&gt; &lt;li&gt; &lt;span&gt;C:\&lt;/span&gt; &lt;ul class="leftbutton" &gt; &lt;li value="List1"&gt;&lt;span&gt;Folder1&lt;/span&gt;&lt;/li&gt; &lt;li value="List2"&gt;&lt;span&gt;Folder2&lt;/span&gt;&lt;/li&gt; &lt;ul&gt; &lt;li value="SubList1"&gt;&lt;span&gt;SubFolder1&lt;/span&gt;&lt;/li&gt; &lt;li value="SubList2"&gt;&lt;span&gt;SubFolder2&lt;/span&gt;&lt;/li&gt; &lt;/ul&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; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload