我只添加了一个......
$(this).replaceWith($('<div> <ul>' + this.innerHTML + '</ul></div>').addClass('card_tr'));
这是我为文本编辑器拍摄的图像,我是新的。
答案 0 :(得分:0)
如果您使用children,您将获得不同的选择器结果集,因此您可以将方法链接在一起以获得所需的效果。
$("DIV").addClass("class-for-div") //Will apply only to the DIV
.children("UL")
.addClass("class-for-ul"); //Will apply only to the UL children and not the DIV itself
答案 1 :(得分:0)
假设您的代码行正常工作......但唯一缺少的是要添加到ul
的类......
为什么不在指定replaceWith()
的内容时添加它?
$(this).replaceWith($('<div> <ul class="HELLO">' + this.innerHTML + '</ul></div>').addClass('card_tr'));
答案 2 :(得分:0)
您可以尝试这种方法。
{{1}}