目前,我有这一行:
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/