我想在动画中查找图像 <div class="text_slider">
并阅读alt=""
其中。
<div id="slider">
<img src="1.png" alt="this is the first image" />
<img src="2.png" alt="this is the second image" />
</div>
我的尝试是:
function afterPic() {
$('.text_slider').animate({
opacity: 0.25,
height: 'toggle'
}, 1000,
function() {
$('.text_slider').html("<p style='z-index: 9998;'>"
+ $('#slider').find('img').this.alt +"</p>");
}
);
但不幸的是它不起作用。
最佳答案
您忘记了 '#slider'
周围的引号,并且错误地使用了 jQuery...
它会成功:$('#slider').find('img').attr('alt')
关于jquery - 在div中找到img并读取alt文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17031394/