D
dennis.sprengers
I wrote a function that browses through the DOM in search for images
with a "tooltip" class. When found, it adds a mouseover event
(createTooltip), but without parameters. createTooltip expects an
image element as input, though:
<img id="img_1" class="tooltip" src="image.png" title="some more
info!">
function findTooltips() {
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var image = images;
if (hasClass(image, 'tooltip')) {
addEvent(image, 'mouseover', createTooltip); // no parameters!
}
}
}
function createTooltip(element) {
alert(element.title); // should return "some more info!"
}
In short: who could help me rebuild findTooltips to call createTooltip
with a parameter? Any help would be greatly appreciated!
with a "tooltip" class. When found, it adds a mouseover event
(createTooltip), but without parameters. createTooltip expects an
image element as input, though:
<img id="img_1" class="tooltip" src="image.png" title="some more
info!">
function findTooltips() {
var images = document.getElementsByTagName('img');
for (var i = 0; i < images.length; i++) {
var image = images;
if (hasClass(image, 'tooltip')) {
addEvent(image, 'mouseover', createTooltip); // no parameters!
}
}
}
function createTooltip(element) {
alert(element.title); // should return "some more info!"
}
In short: who could help me rebuild findTooltips to call createTooltip
with a parameter? Any help would be greatly appreciated!