gpt4 book ai didi

jquery - 应用之前的选择器后应用选择器

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

我在一个页面上有多个带有 .product1 的项目。当用户将鼠标悬停在缩放按钮上时,我想获取 image 类的 HTML。我尝试通过:

$(this).closest(".product1")(".image").html()

但是什么也没有返回。

这是我的代码:

$(document).ready(function () {
$(".productzoom").hover(function () {//also add this function to click
console.log($(this).closest(".product1")(".image").html());
});
});


<div class="product1">
<div class="prodtitle">
<span itemprop="name"><asp:Literal ID="Literal11" runat="server" /></span>
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<div class="price">
<span itemprop="price"><asp:Literal ID="Literal12" runat="server" /> <asp:Literal ID="Literal13" runat="server" /> <asp:Literal ID="Literal14" runat="server" /></span>
</div>
</div>
<div class="description">
<div class="image">
<a href="http://www.bing.com?id=1"><img src="/images/logo_nl.png" style="max-width:100px" alt="Deckchairs" /> <!--thumbnail image-->
<span> <!--span contains the popup image-->
<img style="max-width:400px" src="/images/logo_nl.png" alt="Deckchairs" /> <!--popup image-->
<br />Deckchairs on Blackpool beach <!--caption appears under the popup image-->
</span>
</a>
</div>


<span itemprop="description"><asp:Literal ID="Literal15" runat="server" /></span>
</div>

<div class="stock"><asp:Literal ID="ltStockStatus" runat="server" /></div>
<div class="actionmenu">
<img src="/images/zoom.png" class="productzoom pointer" />
<a class="link viewproduct" href="#" title="">view</a>
<a class="link orderproduct" rel="nofollow" href="#" target="_blank" title="">order</a>
</div>
</div>

最佳答案

您刚刚遗漏了.find()

用途:

$(document).ready(function () {
$(".productzoom").hover(function () {//also add this function to click
console.log( $(this).closest(".product1").find(".image").html() );
});
});

<强> jsFiddle example

关于jquery - 应用之前的选择器后应用选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19757320/

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