>>求教什么使用javascript完成当点击列表一行,那一行的复选框选中,点中复选框那行选中? 这个问题看起来有点不知所云,不知道我理解错了没有……直接在html里面就可以完成,不用写脚本:
<TABLE>
<label for=checkbox1>
<TR style="cursor:pointer">
<TD><input type=checkbox id=checkbox1></TD>
<TD>test</TD>
<TD>test</TD>
</TR>
</label>
<label for=checkbox2>
<TR style="cursor:pointer">
<TD><input type=checkbox id=checkbox2></TD>
<TD>test</TD>
<TD>test</TD>
</TR>
</label>
<label for=checkbox3>
<TR style="cursor:pointer">
<TD><input type=checkbox id=checkbox3></TD>
<TD>test</TD>
<TD>test</TD>
</TR>
</label>
</TABLE>在非IE浏览器里面就不能偷懒了:<TABLE>
<TR>
<TD><input type=checkbox id=checkbox1></TD>
<TD><label for=checkbox1 style="cursor:pointer">test</label></TD>
<TD><label for=checkbox1 style="cursor:pointer">test</label></TD>
</TR>
<TR style="cursor:pointer">
<TD><input type=checkbox id=checkbox2></TD>
<TD><label for=checkbox2 style="cursor:pointer">test</label></TD>
<TD><label for=checkbox2 style="cursor:pointer">test</label></TD>
</TR>
</label>
<TR style="cursor:pointer">
<TD><input type=checkbox id=checkbox3></TD>
<TD><label for=checkbox3 style="cursor:pointer">test</label></TD>
<TD><label for=checkbox3 style="cursor:pointer">test</label></TD>
</TR>
</TABLE>用脚本也好做:<TABLE>
<TR onclick="test(this)">
<TD><input type=checkbox></TD>
<TD>test</TD>
<TD>test</TD>
</TR>
<TR onclick="test(this)">
<TD><input type=checkbox></TD>
<TD>test</TD>
<TD>test</TD>
</TR>
<TR onclick="test(this)">
<TD><input type=checkbox></TD>
<TD>test</TD>
<TD>test</TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function test(e){
e.getElementsByTagName("input")[0].click();
}
//-->
</SCRIPT>