-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
38 lines (36 loc) · 954 Bytes
/
test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>document示例</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>
var 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>