Find / Replace Text Within Matching Selectors Using jQuery

By June 27, 2016March 17th, 2017Blog, Javascript, jQuery
Allure Web Solutions Code Snippet
$.fn.extend({
  findReplace: function(find, replace) {
    $(this).text(function() {
      return $(this).text().replace(find, replace);
    });
  }
});

Usage

$('.selector').findReplace('This is replace', 'With This');

CodePen Example

See the Pen Replace Partial Text Using jQuery by Mike Doubintchik (@allurewebsolutions) on CodePen.

Mike Doubintchik

Author Mike Doubintchik

More posts by Mike Doubintchik

Leave a Reply