gpt4 book ai didi

jquery - 为什么我的 jQuery 选择器不起作用?

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

我正在编写一个简单的脚本来替换两个图像。第一个可以正常交换,但第二个由于某种原因不会触发。这一定是我所缺少的简单的东西。也许是“div.singleTint img”选择器?有人可以看一下并仔细检查我的工作吗?

这是我的 HTML:

    <div id="beerGlassOverlay">
<img src="<?php bloginfo('template_directory'); ?>/images/beerOverlay.png" class="glassreplace">
</div>

<li class="image-rollover">
<a href="http://brasco.co/Mims/meet-the-breweries/miller-beers/" target="_blank">
<img width="177" height="186" src="http://brasco.co/Mims/wp-content/uploads/2012/05/miller1.png" class="attachment-full wp-post-image" alt="miller" title="miller" />
</a>
<div class="singleTint">
<img width="279" height="524" src="http://brasco.co/Mims/wp-content/uploads/shrekBeer.png" class="attachment-full" alt="shrekBeer" title="shrekBeer" />
</div><!-- End singleTint-->
</li>

这是我的 jQuery:

$('li.image-rollover').mouseover(function() {   
$('img.glassreplace').attr({//Change the src and size info on hover
src: ('div.singleTint img', this).src,
width: '100%',
height: '100%'
});
});`

最佳答案

更改此:

src: ('div.singleTint img', this).src,

至:

src: $('div.singleTint img', this).attr('src'),

关于jquery - 为什么我的 jQuery 选择器不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11311479/

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