首页 > 代码库 > 五角星随鼠标移动显示的效果
五角星随鼠标移动显示的效果
<!DOCTYPE html> <meta charset="UTF-8"><html> <head> <title></title> <script type="text/javascript"> var isclick = false; function initEvent() { var tableWjx = document.getElementById("tableWjx"); var tds = tableWjx.getElementsByTagName("td"); for (var i = 0; i < tds.length; i++) { var td = tds[i]; td.onmouseover = change; td.onmouseout = repeal; td.onclick = change1; } } function change() { if (!isclick) { var tableWjx = document.getElementById("tableWjx"); var tds = tableWjx.getElementsByTagName("td"); var index = indexof(tds, this); for (var i = 0; i < index + 1; i++) { var td = tds[i]; td.innerText = "★"; } } } function repeal() { if (!isclick) { var tableWjx = document.getElementById("tableWjx"); var tds = tableWjx.getElementsByTagName("td"); var index = indexof(tds, this); for (var i = 0; i < index + 1; i++) { var td = tds[i]; td.innerText = "☆"; } } } function indexof(arr, ele) { for (var i = 0; i < arr.length; i++) { if (arr[i] == ele) { return i; } } return -1; } function change1() { if (!isclick) { change(); isclick = true; } else { alert("Sorry,You had clicked me!"); } } </script> </head> <body onl oad="initEvent()"> <table id="tableWjx"><tr><td>☆</td><td>☆</td><td>☆</td><td>☆</td><td>☆</td></tr></table> </body> </html>
五角星随鼠标移动显示的效果
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。