3个回答
展开全部
<table border="1">
<tr><td><input type="checkbox"></td><td>1111111</td></tr>
<tr><td><input type="checkbox"></td><td>2222222</td></tr>
<tr><td><input type="checkbox"></td><td>3333333</td></tr>
<tr><td><input type="checkbox"></td><td>4444444</td></tr>
</table>
<script>
var chkBoxs = document.getElementsByTagName("input");
for(var i=0;i<chkBoxs.length;i++){
chkBoxs[i].onclick=function(){
tdText = this.parentNode.parentNode.childNodes[1];
if(this.checked){
tdText.style.fontWeight = "bold";
tdText.style.color = "red";
tdText.style.background = "yellow";
}else{
tdText.style.fontWeight = "normal";
tdText.style.color = "black";
tdText.style.background = "white";
}
};
}
</script>
<tr><td><input type="checkbox"></td><td>1111111</td></tr>
<tr><td><input type="checkbox"></td><td>2222222</td></tr>
<tr><td><input type="checkbox"></td><td>3333333</td></tr>
<tr><td><input type="checkbox"></td><td>4444444</td></tr>
</table>
<script>
var chkBoxs = document.getElementsByTagName("input");
for(var i=0;i<chkBoxs.length;i++){
chkBoxs[i].onclick=function(){
tdText = this.parentNode.parentNode.childNodes[1];
if(this.checked){
tdText.style.fontWeight = "bold";
tdText.style.color = "red";
tdText.style.background = "yellow";
}else{
tdText.style.fontWeight = "normal";
tdText.style.color = "black";
tdText.style.background = "white";
}
};
}
</script>
展开全部
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>翔</title>
<script language="javascript">
function change(){
if(document.getElementById("changes").checked==true){
document.getElementById("change").style.backgroundColor="#0000FF";
document.getElementById("change").style.fontWeight="bold";
}else if(document.getElementById("changes").checked==false){ //点击取消的时候叫他恢复样式
document.getElementById("change").style.backgroundColor="#ffffff";
document.getElementById("change").style.fontWeight="normal";
}
}
</script>
</head>
<body>
<input type="checkbox" id="changes" onclick="change()" />
<table border="1">
<tr>
<td id="change">哈哈,样式变了哦</td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>翔</title>
<script language="javascript">
function change(){
if(document.getElementById("changes").checked==true){
document.getElementById("change").style.backgroundColor="#0000FF";
document.getElementById("change").style.fontWeight="bold";
}else if(document.getElementById("changes").checked==false){ //点击取消的时候叫他恢复样式
document.getElementById("change").style.backgroundColor="#ffffff";
document.getElementById("change").style.fontWeight="normal";
}
}
</script>
</head>
<body>
<input type="checkbox" id="changes" onclick="change()" />
<table border="1">
<tr>
<td id="change">哈哈,样式变了哦</td>
</tr>
</table>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
document.getElementById("test").stlyle.xxxx = xxxx
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询