script onload function var col document getElementsByTagName input for

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script>
onload = function ()
{
var col = document.getElementsByTagName ('input');
for (var j = 0, J = col.length; j < J; j++)
if (col [j].getAttribute ('hint'))
col [j].nextSibling.onmouseover = function ()
{
var q = document.getElementById ('tol'), obj = this, l = 34, t = -12;
q.innerHTML = this.previousSibling.getAttribute ('hint');
while (obj.offsetParent)
l += obj.offsetLeft, t += obj.offsetTop, obj = obj.offsetParent;
with (q.style)
left = l + 'px', top = t + 'px', display = 'block';
},
col [j].nextSibling.onmouseout = function ()
{document.getElementById ('tol').style.display = 'none'}
}
</script>
<div id="tol" style="position: absolute;
display: none;
width: 123px;
height: 54px;
border: 1px solid #000;
background: #ccc;
padding: 5px"></div>
<p><input hint="первая подсказка"><img src="картинка со знаком вопроса">
<p><input hint="вторая подсказка"><img src="картинка со знаком вопроса">
<p>...
<p><input hint="последняя подсказка"><img src="картинка со знаком вопроса">