gpt4 book ai didi

javascript - 使用 Jquery 将 Iframe 插入到类中

转载 作者:行者123 更新时间:2023-11-28 19:56:55 25 4
gpt4 key购买 nike

下面的脚本将一个 iframe 插入到 rightImage 类中。问题是有多个元素使用 rightImage 类,因此 iframe 显示多次。我如何获取它,以便它只添加使用 rightImage 类的最后一个元素,因此 iframe 只出现一次?

 $(document).ready(function() {
$(".rightImage").append("<iframe src='test.uk'></iframe>");
});

我无法控制父页面,因此我必须这样做。

最佳答案

您可以使用:last 选择器:

Selects the last matched element.

$(".rightImage:last").append("<iframe src='test.uk'></iframe>");

.last() :

Reduce the set of matched elements to the final one in the set.

$(".rightImage").last().append("<iframe src='test.uk'></iframe>");

关于javascript - 使用 Jquery 将 Iframe 插入到类中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22380987/

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