<input type="button" name="select" οnclick="checkAll('test')" value="全选"/>
<tr>
<td><input type="checkbox" name="test" /></td>
<td>林林</td>
<td>13001010888</td>
<td>丽丽</td>
<td>有意向</td>
<td>545</td>
<td><a href="#"><button>修改</button></a>
<a href="#"><button>删除</button></a>
</tr>
<tr>
<td><input type="checkbox" name="test" /></td>
<td>林林</td>
<td>13001010888</td>
<td>丽丽</td>
<td>有意向</td>
<td>545</td>
<td><a href="#"><button>修改</button></a>
<a href="#"><button>删除</button></a>
</tr>
<input type="button" name="select" οnclick="clearAll('test')" value="取消全选"/>
<script type="text/javascript">
function checkAll(name) {
var el = document.getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if ((el[i].type == "checkbox") && (el[i].name == name)) {
el[i].checked = true;
}
}
}
function clearAll(name) {
var el = document.getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if ((el[i].type == "checkbox") && (el[i].name == name)) {
el[i].checked = false;
}
}
}
</script>
<tr>
<td><input type="checkbox" name="test" /></td>
<td>林林</td>
<td>13001010888</td>
<td>丽丽</td>
<td>有意向</td>
<td>545</td>
<td><a href="#"><button>修改</button></a>
<a href="#"><button>删除</button></a>
</tr>
<tr>
<td><input type="checkbox" name="test" /></td>
<td>林林</td>
<td>13001010888</td>
<td>丽丽</td>
<td>有意向</td>
<td>545</td>
<td><a href="#"><button>修改</button></a>
<a href="#"><button>删除</button></a>
</tr>
<input type="button" name="select" οnclick="clearAll('test')" value="取消全选"/>
<script type="text/javascript">
function checkAll(name) {
var el = document.getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if ((el[i].type == "checkbox") && (el[i].name == name)) {
el[i].checked = true;
}
}
}
function clearAll(name) {
var el = document.getElementsByTagName('input');
var len = el.length;
for (var i = 0; i < len; i++) {
if ((el[i].type == "checkbox") && (el[i].name == name)) {
el[i].checked = false;
}
}
}
</script>