gpt4 book ai didi

jquery - 在div中找到img并读取alt文本

转载 作者:行者123 更新时间:2023-12-01 06:49:38 25 4
gpt4 key购买 nike

我想在动画中查找图像 <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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com