Currently I am using this script (http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html) on my website - www.tompainetoday.com.

It works when you hover your mouse over a "Trending Now:" term, then that word is highlighted throughout the page. The highlighting is removed when you hover over the header image (yes, I know, poor UX, but it works).

The problem arrises when the trending word is short, and ends up being highlighted inside of other, larger words, since this script makes no distinction between words and a list of characters.

Basically, I think this can be done rather easily by only highlighting the characters if the character prior and after the word are not a letter.

I tweeted the developer of this script and suggested it be edited with:
new RegExp("\W" + pat + "\W").test
I have no experience with regex, and only minimal with JavaScript.

Any help in fixing this out would be much apprecaited!


4 Years
Discussion Span
Last Post by pritaeas

The above line: "I tweeted the developer of this script and suggested it be edited with:"
Should read: "I tweeted the developer of this script and he suggested it be edited with:"

Edited by paine_today


I don't know. I thought the developer told you where to change it. If you can't get it to work, I have something similar here.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.