Reputation: 148
can you please tell me how to remove the span tag using jquery. INPUT
<span class="abc">PQR </span>
OUTPUT
PQR
I done before but don't remember I think I used regex or replace .:(
Second
How to replace   by a space(" ") ?
I used like that but not work.
replace(/ /g,'');
Upvotes: 1
Views: 178
Reputation: 8978
For the first part, you can use $('.abc').contents().unwrap()
For the second part see jods answer :)
Upvotes: 2
Reputation: 4591
For the first part, Tim's answer is great. $('.abd').contents().unwrap()
.
For the second part, please do it properly.
is an html-encoded special characters (non-breakable space), but there are tons of other characters you can encounter (like é
for é
).
Unfortunately there's no built-in standard html decode function, but you can create one with jquery like this:
function htmlDecode(encodedText) {
return $("<div>").html(encodedText).text();
}
Upvotes: 3