首页 > 代码库 > 五角星评分效果
五角星评分效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>JavaScript星级评分</title> <style type="text/css"> * { margin: 0; padding: 0; } .wrapper { height: 20px; padding: 5px; width: 130px; margin: 100px auto 10px; } tr, td { font-size: 66px; color: #000000; background: #ffffff; } </style> <script type="text/javascript"> function ArrayIndexOf(arr, element) { for(var i = 0; i < arr.length; i++) { if(arr[i] == element) { return i; } } return -1; } function GetTds() { var tbl = document.getElementById("tblMain"); var tds = tbl.getElementsByTagName("td"); return tds; } function InitEvent() { var tds = GetTds(); for(var i = 0; i < tds.length; i++) { var td = tds[i]; td.onmouseover = TdOnclick; td.style.cursor = "pointer"; } } function TdOnclick() { var tds = GetTds(); var index = ArrayIndexOf(tds, this); for(var i = 0; i <= index; i++) { var td = tds[i]; td.innerHTML = "★"; } for(var j = index + 1; j < tds.length; j++) { var td = tds[j]; td.innerHTML = "☆"; } } </script> </head> <body onl oad="InitEvent()" class="wrapper"> <table id="tblMain"> <tr> <td>☆</td> <td>☆</td> <td>☆</td> <td>☆</td> <td>☆</td> </tr> </table> </body> </html>
五角星评分效果
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。