gpt4 book ai didi

jQuery 删除除 anchor 之外的所有 HTML 标签

转载 作者:搜寻专家 更新时间:2023-10-31 22:23:41 25 4
gpt4 key购买 nike

目前,我有这一行:

this.html(this.html().replace(/\x3C\x2F?[^\x3E]+\x3E/gi, ''));

但是,我想说一些类似“if 子句”的东西,

IF (this.tag = "<a") {
do nothing
} ELSE {
remove tag
}

我想没有人有任何想法吗?

[编辑]:我想我可能必须做一个“FOR EACH”循环……我想……[/EDIT]

^.^

最佳答案

jQuery 有“:not”伪选择器。

$(':not(a)', this).remove()

关于jQuery 删除除 anchor 之外的所有 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3083225/

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