gpt4 book ai didi

javascript - jquery在第二张图片后面插入一个div

转载 作者:行者123 更新时间:2023-11-28 20:09:39 25 4
gpt4 key购买 nike

我正在使用下面的代码在第一个图像之后插入一个 div,效果很好。是否可以将其插入到第二张图片之后?

我的代码是:

$(document).ready(function () {
$(".gdl-blog-full").find("img:first").after("<div id='1' style='width:800px; height:90px; float: left; margin-top:10px; margin-bottom:15px;'><div class='gad' style='width: 728px; height:90px; float: left; margin-left: 36px;'></div></div>");
});

最佳答案

尝试:eq:nth() 相同

$(".gdl-blog-full").find("img:nth(1)")

:nth(),:eq() index starts from 0

:nth-child()

$(".gdl-blog-full").find("img:nth-child(2)")

:nth-child() index starts from 1

.eq()

$(".gdl-blog-full").find("img").eq(1)

关于javascript - jquery在第二张图片后面插入一个div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20121129/

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