gpt4 book ai didi

jQuery 用 anchor 包裹 img

转载 作者:行者123 更新时间:2023-12-03 22:38:12 27 4
gpt4 key购买 nike

您好,如果类有 anchor ,我会尝试用 anchor 包裹图像。

jQuery:

if ( $(".views-row:has(a)").length) {
var noderef = $(this).attr("anchor");
$(".views-field-field-teaserbox-fid img").wrap("[anchor = "'+noderef+'" ]");
}

HTML:

    <div class="view-content">
<div class="views-row">

<div class="views-field-field-node-ref-nid">
<span class="field-content"><a class="active" href="/all-essentials-inspiring-events">All the essentials of inspiring events.</a></span>
</div>

<div class="views-field-field-teaserbox-fid">
<span class="field-content"><img width="208" height="137" src="http://localhost:8888/sites/default/files/wedding_Giveaway_teaser.jpg?1283880578" alt="" class="imagefield imagefield-field_teaserbox"></span>
</div>

另外,我应该使用双引号还是单引号?

最佳答案

这个怎么样?

$("img.anchor").wrap('<a href="#" />');

引用:http://api.jquery.com/wrap/

关于jQuery 用 anchor 包裹 img,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3664042/

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