gpt4 book ai didi

jQuery:如何 append $(this)

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

我有一个 jQuery 方法,我想将元素 $(this) append 到其中。

我的代码是

$("#actions ul" ).append($(this)); 

但是这似乎确实有作用。使用线路

.append($(this).html()) 

确实有效,但它只抓取 $(this) 的子元素(一个 div),而不是整个元素(一个 li)。

我可能正在做一些愚蠢的事情,希望有人能向我指出这一点。

最佳答案

在不确切知道 this 指的是什么的情况下,我能想到的唯一原因是 $(this).html() 起作用,而不是 $( this) 是前一种方法从 html 代码创建一个新元素,而 append $(this) 将移动该元素。

看看以下方法是否可以解决您的问题:

$("#actions ul" ).append($(this).clone()); 

关于jQuery:如何 append $(this),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4242015/

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