jQuery Removing specific text from an element

If you wanted to find every element with “By:” in it and remove it, you could try this:

$(':contains("By:")').each(function(){
    $(this).html($(this).html().split("By:").join(""));
});

This removes any occurrence of “By:” in any element. If you want to target specfic type of elements, simply change $(':contains("By:")') to include whatever selector suits you.

Leave a Comment