This time I will share jQuery Plugin and tutorial about jQuery Plugin To Replace Any Text Within Document – ReplaceMe, hope it will help you in programming stack.
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.
1 |
< script src = "//code.jquery.com/jquery.min.js" ></ script > |
2 |
< 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>
1 |
$( '.container' ).replaceMe({ |
2 |
textToReplace: 'aliquet' , |
3 |
replaceWithText: '<span class="label label-default">Other Text</span>' , |
3. Set the globally
to false
to only replace the first matched text.
1 |
$( '.container' ).replaceMe({ |
2 |
textToReplace: 'aliquet' , |
3 |
replaceWithText: '<span class="label label-default">Other Text</span>' , |
4. Set excluded HTML tags which should be ignored.
1 |
$( '.container' ).replaceMe({ |
2 |
textToReplace: 'aliquet' , |
3 |
replaceWithText: '<span class="label label-default">Other Text</span>' , |
This awesome jQuery plugin is developed by danielgasser. For more Advanced Usages, please check the demo page or visit the official website.