jQuery的李HREF
问题描述:
喜的父母得到我想要得到这个李jQuery的李HREF
<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>
我怎样才能获得的“身份识别码”父HREF的父。
我只有这个
document.write($('#myid').parent('li').find('a').attr('href'));
该款显示器 “... /陈列室/指数”,我使用document.write()的只是为了测试。
我希望它显示 “.../wheretobuy”,它必须通过 “身份识别码”
这里访问它是在这里
http://fiddle.jshell.net/86powers/YLYxF/
感谢
答
$('#myid').closest('ul').parent().find('a').attr('href')
这应该工作。
+0
谢谢你做到了 – 2013-02-16 09:46:19
如果您在Firefox中使用Firebug或使用Chrome Web Inspector,则可以使用'console.log(text);'输出文本。 – 2013-02-16 09:39:53