gpt4 book ai didi

jQuery .append 外部标签

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

我对 jQuery 完全陌生。老实说,这是我的头几天。

这是我的第一个问题。

$(document).ready(function() {
$('span.head-span').parent().addClass('head-h').append('<div class="clx" />')
});

结果我得到了这个

<h1 class="head-h"><span class="head-span">This is Some Heading</span><div class="clx"/></h1>

我需要在 jQuery 中做什么才能让我的 .clx 出现在 .像这样

<h1 class="head-h"><span class="head-span">This is Some Heading</span></h1><div class="clx"/>

提前非常感谢您。

最佳答案

您应该能够使用after()来做到这一点而不是 append()

$('span.head-span').parent().addClass('head-h').after('<div class="clx" />')

关于jQuery .append 外部标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1462726/

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