javascript - Jquery get parent of li href -
hi want parent of li
<li><a href="/panasonic/index.php/en/site/wheretobuy" class="wtb"></a> <ul> <li><a href="/panasonic/index.php/en/showroom/index" id="myid" > testing</a> </li> </ul> </li>
how can parent href of "myid".
all have
document.write($('#myid').parent('li').find('a').attr('href'));
which displays ".../showroom/index", utilize document.write() test.
i want display ".../wheretobuy" , has accessed via "myid"
here here
http://fiddle.jshell.net/86powers/ylyxf/
thanks
$('#myid').closest('ul').parent().find('a').attr('href')
this should work.
javascript jquery
No comments:
Post a Comment