sean commented on a Page, Highlight Keywords on Page with jQuery  -  May 22, 2013

Great snippet! However, I might have made this a jQuery plugin instead (since we're in the jQuery section :P). This way you could chain the element while offering other (future) parameters. Consider the following implementation:

$('element').highlightWords({
  words: ['keyword1', 'keyword2'],
  effect: 'fadeIn'
});

Is there a reason you decided against that route?

Hawkee  -  May 22, 2013

Good idea! It was really just a quick feature-add, so I didn't flesh it out as much as you suggested. I might just do that if I come back around to working on this again.

diegotucholga  -  Mar 30, 2016

No need for this function anymore. There's a plugin with much more options: mark.js
(Github: https://github.com/julmot/mark.js)

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.