当我鼠标点击那个复选框的时候为什么无法选中呢?
我加了一个鼠标事件,就是当鼠标在<tr>内时候选中复选框
但是
当我鼠标点击那个复选框的时候为什么无法选中呢?
<html>
<head>
<script type="text/javascript">
// 产品管理鼠标事件
var productMouseDown = function(id)
{
if (document.getElementById('price_' + id).checked == false) {
document.getElementById('price_' + id).checked = true;
}
}
</script>
</head>
<body>
<table>
<tr onmousedown="return productMouseDown(1)">
<td width="150">
¥<input type="checkbox" value="" class="w50" id="price_1">
<span class="manage-p-t">10-01-18</span>
</td>
<td width="150">
ddddddddd
</td>
</tr>
<tr onmousedown="return productMouseDown(2)">
<td width="150">
¥<input type="checkbox" value="" class="w50" id="price_2">
<span class="manage-p-t">10-01-18</span>
</td>
<td width="150">
ddddddddd
</td>
</tr>
<tr onmousedown="return productMouseDown(3)">
<td width="150">
¥<input type="checkbox" value="" class="w50" id="price_3">
<span class="manage-p-t">10-01-18</span>
</td>
<td width="150">
ddddddddd
</td>
</tr>
</table>
</body>
</html>
但是
当我鼠标点击那个复选框的时候为什么无法选中呢?
<html>
<head>
<script type="text/javascript">
// 产品管理鼠标事件
var productMouseDown = function(id)
{
if (document.getElementById('price_' + id).checked == false) {
document.getElementById('price_' + id).checked = true;
}
}
</script>
</head>
<body>
<table>
<tr onmousedown="return productMouseDown(1)">
<td width="150">
¥<input type="checkbox" value="" class="w50" id="price_1">
<span class="manage-p-t">10-01-18</span>
</td>
<td width="150">
ddddddddd
</td>
</tr>
<tr onmousedown="return productMouseDown(2)">
<td width="150">
¥<input type="checkbox" value="" class="w50" id="price_2">
<span class="manage-p-t">10-01-18</span>
</td>
<td width="150">
ddddddddd
</td>
</tr>
<tr onmousedown="return productMouseDown(3)">
<td width="150">
¥<input type="checkbox" value="" class="w50" id="price_3">
<span class="manage-p-t">10-01-18</span>
</td>
<td width="150">
ddddddddd
</td>
</tr>
</table>
</body>
</html>
...全文
相关推荐
js实现表格变色(鼠标移动 选中变色)
鼠标移动到表格中时该行变色 离开时恢复 选中该行的复选框时变色 离开后不变色 取消选中后恢复
jquery 实现鼠标单击行时,选中checkbox复选框
jquery 实现鼠标单击行时,改变行的背景颜色,选中checkbox复选框
QT QTreeWidget添加复选框
1、给QTreeWidget添加复选框,实现部分选中,全部选中。 2、如果部分选中,父级复选框为对勾,则需设置风格。
js实现选中复选框文字变色的方法
主要介绍了js实现选中复选框文字变色的方法,涉及javascript鼠标事件及页面元素的相关操作技巧,具有一定参考借鉴价值,需要的朋友可以参考下
js获取checkbox复选框选中的选项实例
有关javascript 获取checkbox复选框的实例数不胜数。 js实现: var form = document.getElementById("form2"); var field = form.elements["test2"]; var option = Dining.getSelectedOption(form, field); var message = ""; for (var i = 0, len = option.length; i < len; i++) { message += "Select id:" + option[i].id + "\nSelected n


