jQuery Plugin To Replace Any Text Within Document - ReplaceMe

File Size: 11.9 KB
Views Total: 383
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin To Replace Any Text Within Document - ReplaceMe

ReplaceMe is an ultra-lightweight jQuery plugin used to replace any text with other text or html in your html document.

How to use it:

1. Load jQuery library and the jQuery ReplaceMe plugin at the end of the document.

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jQueryReplaceMe.js"></script>

2. Call the function on target container to replace text aliquet with <span class="label label-default">Other Text</span>

$('.container').replaceMe({
  textToReplace: 'aliquet',
  replaceWithText: '<span class="label label-default">Other Text</span>',
});

3. Set the globally to false to only replace the first matched text.

$('.container').replaceMe({
  textToReplace: 'aliquet',
  replaceWithText: '<span class="label label-default">Other Text</span>',
  globally: false
});

4. Set excluded HTML tags which should be ignored.

$('.container').replaceMe({
  textToReplace: 'aliquet',
  replaceWithText: '<span class="label label-default">Other Text</span>',
  globally: false,
  excludedTags: [
    'img',
    'span'
  ]
});

This awesome jQuery plugin is developed by danielgasser. For more Advanced Usages, please check the demo page or visit the official website.