简体   繁体   中英

not able to select children of a unordered list using jquery?

I am using a jquery mobile navigation where i have to select the children of a list item , but i dont know for some reason i am having trouble doing this, can anyone help? here is fiddle of what i did till now - http://jsfiddle.net/jhrz9/

 <div data-role="panel" id="left-panel" data-theme="a" data-display="push">
    <ul class="left-nav" data-icon="" data-role="listview" data-autodividers="true" data-filter="true" data-inset="true">
        <li><a href="#">Adam Kinkaid</a><div class="helperText">Helper Text</div></li>
        <li><a href="#">Alex Wickerham</a></li>
        <li><a href="index2.html">Avery Johnson</a></li>
        <li><a href="index.html">Bob Cabot</a></li>
        <li><a href="index.html">Caleb Booth</a></li>
        <li><a href="index.html">Christopher Adams</a></li>
        <li><a href="index.html">Culver James</a></li>
    </ul>
</div><!-- /panel -->

and the script which i am using is

$('ul.left-nav li').click(function(){
    alert($(this).children('.helperText').html());
});

and i have tried this also

$('#left-panel ul li').click(function(){
    alert($(this).children('.helperText').val());
});  

looks like jQuery Mobile changes the dom structure

$('ul.left-nav li').click(function(){
    alert($(this).find('.helperText').html());
});

Demo: Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM