<a onclick="fieldDetail('machineNO')" style="text-decoration: none" href="#">
<font color="#757F7F">设备号(machineNO)</font>
</a>
<input id="PRO_CoreFP" type="CheckBox" value="RecordTime,">function fieldDetail(fielddata) {
this.next().attr("checked", true);
} 我现在就是想选中checkbox后面的文字让前面的checkbox自动变成选中状态,怎么弄?this.next().attr("checked", true);不能实现
<font color="#757F7F">设备号(machineNO)</font>
</a>
<input id="PRO_CoreFP" type="CheckBox" value="RecordTime,">function fieldDetail(fielddata) {
this.next().attr("checked", true);
} 我现在就是想选中checkbox后面的文字让前面的checkbox自动变成选中状态,怎么弄?this.next().attr("checked", true);不能实现
next是指下个兄弟节点吧。。
<script type='text/javascript'>
function fieldDetail(a){
a.checked=true;
}
</script>html代码
<a onclick="fieldDetail(this.nextSibling)" style="text-decoration: none" href="#">
<script type="text/javascript" src="jq/jquery-1.3.2.js"></script>
<script type="text/javascript">
$(function(){
$("#bb").click(function(){
$("#aa").attr("checked",true);
});
});
</script>
<body>
<input type="checkbox" name="aa" id="aa"><br>
<span id="bb">单击这里</span>
</body>
function fieldDetail(fielddata) {
//this不是jQuery对象,this.next()难道没有报错吗?信你的邪
$(this).next().attr("checked", true);
}
<a onclick="fieldDetail(this,'machineNO')" style="text-decoration: none" href="#">
<font color="#757F7F">设备号(machineNO)</font>
</a>
<input id="PRO_CoreFP" type="CheckBox" value="RecordTime,">
function fieldDetail(sender,fielddata) {
//this.next().attr("checked", true);
//this不是jQuery对象,this.next()难道没有报错吗?信你的邪
$(sender).next().attr("checked", true);
} 上面也不对,你直接this,这个时候this指向的是window
var i=0;
$("#bb").onselect=function(){i=1;
}
$("#bb").onmouseup=function(){
if (i==1){
$("#aa").attr("checked",true);
}
}
</script>