i’m trying to loop through divs which has specific string to replace it with another one
inside html i have divs with class “meta” some of them contain word like facebook twitter and they are links and i want to replace only the word facebook with a space to delete it and keep the link of twitter as it is so i’m using this code
$(document).ready(function(e) {
$(".meta").each(function() {
var newstring = $(this).text();
if(newstring.indexOf('facebook') >= 0){
news = newstring.replace('facebook','');
}
$(this).html(news);
});
});
but the the twitter appears as just text not a link and when using
var newstring = $(this).html();
nothing happens it doesn’t replace the string any help please
Thakns in advance
Use a combination of
:containsand.remove().