Reputation: 5025
<div class="example">Some example text</div>
<div class="example">Some more example text</div>
How can I remove all instances of the letter 'e' (case sensitivity not necessary) in the elements above without preexisting ids?
Upvotes: 1
Views: 782
Reputation: 25135
var de = document.documentElement;
de.innerHTML = de.innerHTML.replace(/>.*?</g, function(a, b) {
return a.replace(/e/g, "f");
});
Upvotes: 0
Reputation: 150253
$('div').each(function() {
this.innerHTML= this.innerHTML.replace(/e/g, '');
});
If you want e
or E
use this:
$('div').each(function() {
this.innerHTML= this.innerHTML.replace(/e|E/g, '');
});
If there are elements inside those <div>
s use the text
function to get only the textNodes:
$('div').each(function() {
$this = $(this);
$this.text($this.text().replace(/e|E/g, ''));
});
Upvotes: 3
Reputation: 8166
Assuming you want to replace the content of the inner text (and not generically all the 'e's inside the tag):
$(yourselector).each(function(){
$(this).text($(this).text.replace(/e/g, ''));
});
PS Corrected after gdoron remark...
Upvotes: 1