Using a regex rule for search a word in JavaScript
Defined a 'Highlight' css class for highlight the keyword.
Final code and demo is here
Demo
new RegExp("Keyword",'gim')And replace the keyword by '<span class=\"Highlight\">Keyword</span>'
Defined a 'Highlight' css class for highlight the keyword.
<style>JQuery 'unwrap()' methord is used for unwrap the previously highlighted elements.
.Highlight
{
background-color:#FF9;
color:#555;
}
</style>
Final code and demo is here
Demo
No comments:
Post a Comment