[英]Get id of img inside selected li using document.activeElement
这是我的HTML代码
<li id="liButton_1" tabindex="2" class="activeli">
<a onclick="ShowVideo('1');">
<img id="ImageButton_1" title="Sister Teresa's Talk (Malayalam)" alt="Sister Teresa"
s="" talk="" (malayalam)
'="" src="http://www.braddockinfotech.com/demo/dvnonline/vod/timthumb/timthumb.php?src=wp-content/uploads/2012/11/Sr.-Teresa.jpg&h=54&w=109&zc=1&a=c" class="active"></a></li>
确定,当选择此li
时,可以像document.activeElement
一样访问它。 如何选择id
的的img
内li
使用document.activeElement。(一些东西)
如果您将li参考作为活动元素
var activeEle = document.activeElement;
var imageID = activeEle.getElementsByTagName("img")[0].getAttribute("id");
使用jQuery非常简单
$("#liButton_1").click(function(){
var img_id = $("#liButton_1 a img").attr('id');
});
尚未测试,但希望能奏效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.