Currently, I have this line:
this.html(this.html().replace(/\x3C\x2F?[^\x3E]+\x3E/gi, ''));
But, I would like something along the lines of an "if clause" to say,
IF (this.tag = "<a") {
do nothing
} ELSE {
remove tag
}
I don't suppose anyone has any ideas?
[EDIT]: I think I may have to do a "FOR EACH" loop... I think.... [/EDIT]
^.^
jQuery has ":not" pseudo-selector.
$(':not(a)', this).remove()
this.html(this.html().replace(/<\/?([b-z]+)[^>]*>/gi, function(match, tag) {
return (tag === "a") ? match : "";
}));
If you are looking at leaving the "a" tags in place, change the regular expression from [a-z] to [b-z]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With