1) CODE TITLE: Automatic Text Tooltip
2) AUTHOR NAME: MJH
3) DESCRIPTION: Quickly create a tooltip for words and phrases contained in your web document, with minimal hand coding. Wrap all the text, not each word or phrase, in a <div> or <span> like this: <div id="subjectMatter"></div>, then choose the words and/or phrases, along with their definitions, for the tooltip by editing a simple array like this:
No other changes to your markup are necesssary other than inserting the "subjectMatter" <div> or <span>.Code:nPairs[nPairs.length] = "numb >" + "unable to experience any sensation"; nPairs[nPairs.length] = "Davenport >" + "the name of the|fictional city in which|this story takes place"; nPairs[nPairs.length] = "slushy >" + "wet, with partially|melted snow"; nPairs[nPairs.length] = "beautiful wings >" + "the visually pleasing|feathered appendages of|birds that allow for flight"; nPairs[nPairs.length] = "countdown >" + "counting backward to|indicate the time remaining|until an event"; nPairs[nPairs.length] = "velvet interrogations >" + "friendly, yet persistent questions";
The code will then automatically find every instance of those words and phrases and wrap them in specially styled <span> tags. Onmouseover the tooltip will be displayed.
The tooltip always displays toward the center of the window, regardless of the position of the hovered element within the document or the size of the browser window.
4) ATTACHED BELOW: .zip file containing the code and demo.



Reply With Quote


Bookmarks