<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script>
onload = function () {
var btns = this.document.getElementsByTagName('input');
for (var i = 0; i < btns.length; i++) {
var dv = document.getElementById('dv');
btns[i].onmouseover = function (e) {
dv.style.display = 'block';
dv.style.left = e.clientX + 'px';
dv.style.top = e.clientY + 'px';
dv.innerHTML = this.id;
};
btns[i].onmouseout = function () {
dv.style.display = 'none';
}
};
};
</script>
</head>
<body>
<input type="button" id="btn1" name="name" value="btn1" />
<input type="button" id="btn2" name="name" value="btn2" />
<input type="button" id="btn3" name="name" value="btn3" />
<div id="dv" style="position:absolute;float:left;display:none;border:1px solid red" ></div>
</body>
</html>
JS-显示Id
最新推荐文章于 2024-04-17 10:19:41 发布