求助,为什么click事件没有反应 为什么点击圆圈不能弹出第几个圆圈的标记 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 click拼错了吧 getElementsByTagName是多个的所以要加下标window.onload = function(){ Li = document.getElementsByTagName("div")[0].getElementsByTagName("li"); LiLength = Li.length; for(let i=0;i<LiLength;i++){ Li[i].index = i; Li[i].onclick = function(){ var index = this.index; alert(index); }; } } <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> *{ margin: 0; padding: 0; } div{ height:100px; width: 550px; border:1px solid black; line-height: 100px; position: relative; } li{ border:1px solid black; list-style: none; display: block; height: 100px; width: 100px; border-radius:50px 50px; float: left; } </style> <script> window.onload = function(){ Li = document.getElementsByTagName("div").getElementsByTagName("li"); Lilength = Li.length; for(let i =0;i<Lilength;i++){ Li[i].index = i; Li[i].onclick = function(){ var index = this.index; alert(index); } } } </script></head><body> <div> <ul> <li class="round"></li> <li class="round"></li> <li class="round"></li> <li class="round"></li> <li class="round"></li> </ul> </div></body></html> li[i].onclink= function()是这个问题么 通过JS是否可以知道客户端使用几个显示器? 求解 在线等!~~~~~~~~~~简单的js问题 请教span中的内容如何靠左显示 求助 JS 树状页面搜索问题 为什么火狐和IE的差别这么大 Javascript inherit problems Cannot read property 'renderer' of undefined 怎样取得某一网页的源代码?? 加入访问密码的JS代码后,每次提交数据,页面刷新都要重新输入一次密码,怎么解决 如何让页面先运行iframe,再显示页面!
Li = document.getElementsByTagName("div")[0].getElementsByTagName("li");
LiLength = Li.length;
for(let i=0;i<LiLength;i++){
Li[i].index = i;
Li[i].onclick = function(){
var index = this.index;
alert(index);
};
}
}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
height:100px;
width: 550px;
border:1px solid black;
line-height: 100px;
position: relative;
}
li{
border:1px solid black;
list-style: none;
display: block;
height: 100px;
width: 100px;
border-radius:50px 50px;
float: left;
}
</style>
<script>
window.onload = function(){
Li = document.getElementsByTagName("div").getElementsByTagName("li");
Lilength = Li.length;
for(let i =0;i<Lilength;i++){
Li[i].index = i;
Li[i].onclick = function(){
var index = this.index;
alert(index);
}
}
}
</script>
</head>
<body>
<div>
<ul>
<li class="round"></li>
<li class="round"></li>
<li class="round"></li>
<li class="round"></li>
<li class="round"></li>
</ul>
</div>
</body>
</html>