Created
May 27, 2013 21:00
-
-
Save bl4de/5659066 to your computer and use it in GitHub Desktop.
While I work on my new project, VirtualAssistant, I created simple code, which allows to add tooltip to any DOM element on page. Of course, I should pass as second argument some kind of callback, which draws tooltip baloon with text, because for now, it's simple 'title' HTML attribute added 'on the fly' :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var VAEngine = VAEngine || ( function() { | |
function addTooltip(_element, _tooltipText) { | |
var _elem = document.querySelector(_element); | |
console.log("_elem: ", _elem); | |
_elem.addEventListener('mouseover', function() { | |
_elem.title = _tooltipText; | |
}); | |
} | |
return { | |
addTooltip: addTooltip | |
}; | |
})(); | |
// usage: | |
// VAEngine.addTooltip("#sample1", "This is sample tooltip number one"); | |
// where: | |
// #sample1 - ID of DOM element | |
// secon argument - content of tooltip | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment