本文主要和大家分享js 实现点亮星星评分功能,希望能帮助到大家。
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<title>点亮星星评分</title></head><body onload="test()"><table id ="czy">
<tr>
<td>★</td><td>★</td><td>★</td><td>★</td><td>★</td>
</tr></table><input type="button" id="ok" value="打分"><script>
tds=document.getElementsByTagName("td"); for(var i=0;i<tds.length;i++){
tds[i].onmouseover=test;
} var index; function test(){
for(var i=0;i<tds.length;i++){ if(tds[i]==this)
{
index=i;
}
} for(var i=0;i<=index;i++) {
tds[i].style.color = "red";
} for(var i=index+1;i<tds.length;i++){
tds[i].style.color="black";
}
}
document.getElementById("ok").onclick=function(){
alert("评分:"+(index+1)+"分");
}</script></body></html>相关推荐:
js点亮星星评分并获取参数的js代码_javascript技巧
以上就是JS 实现点亮星星评分功能的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号