gpt4 book ai didi

jQuery 添加/链接元素到一个变量

转载 作者:行者123 更新时间:2023-12-01 01:35:34 24 4
gpt4 key购买 nike

我怎样才能把它变成更快的东西:

$.each(data, function(key, val) 
{
rcItemsLi.eq(index++).append('<div class="rc-item-content clear hidden"><p class="rc-item-context">' + val[0] + '</p>' + val[1] + '</div>');
});
rcItemsContent = $('.rc-item-content');

在此示例中,我首先将元素附加到我想要的位置,然后使用 .rc-item-content 选择器“查找”所有元素并将它们存储在 rcItemsContent 变量中。


例如:

$.each(data, function(key, val) 
{
rcItemsContent.add($('<div class="rc-item-content clear hidden"><p class="rc-item-context">' + val[0] + '</p>' + val[1] + '</div>').appendTo(rcItemsLi.eq(index++)));
});

在此示例中,我想要实现的目标(当然我没有)是添加/链接变量中的元素,并将其同时附加到我想要的位置。

最佳答案

.add 创建一个新集合。

rcItemsContent = rcItemsContent.add(...

关于jQuery 添加/链接元素到一个变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14540443/

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