How to get link inside li with jQuery? -


my html:

<div id="mydiv">         <ul class="myclass" style="display: block;">             <li class="directory selected">             <a href="#" rel="src/fd/">fd</a>                 <ul class="jqueryfiletree" style="display: block;">                     <li class="file ext_jpg">                     <a href="#">drevilblu.jpg</a>                     </li>                 </ul>             </li>         </ul>     </div> 

i need fd query:

var foldername = $("#mydiv").find("li.selected a").text(); 

but receive drevilblu.jpg instead.
how a inside li class="directory selected"

try following

var foldername = $("#mydiv").find("li.selected > a").text(); 

you need first level child of li class selected. need >


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -