1.创建table表格,要求:
点击某一行,则该行变色(选中)。
2.用下拉列表框实现省市级联效果。
<select>
<option value=""></option>
</select>
提示:使用数组
点击某一行,则该行变色(选中)。
2.用下拉列表框实现省市级联效果。
<select>
<option value=""></option>
</select>
提示:使用数组
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>选中行并变色</title>
<script>
function tagsCheck(j){
var x=document.getElementsByTagName("tr").length;
//遍历获取表格中的信息
for(var i=0;i<x;i++){
var temp = document.getElementsByTagName("tr")[i];
if (j == temp) {
//鼠标选中的标签样式
temp.style.background = "#00FF00";
} else {
//恢复原来的背景颜色
temp.style.background = "";
}
}
}
</script>
</head>
<body>
<table border="1px" align="center" bgcolor="aquamarine">
<tr οnclick="tagsCheck(this)">
<td>第一行内容</td>
<td>身体健康</td>
</tr>
<tr οnclick="tagsCheck(this)">
<td>第二行内容</td>
<td>学业进步</td>
</tr>
<tr οnclick="tagsCheck(this)">
<td>第三行内容</td>
<td>每天开心</td>
</tr>
</table>
</body>
</html