<html>
<head>
<title>test page</title>
<meta http-equiv="content-type" content="text/htmlcharset=utf-8">
</head>
<body>
<input type="checkbox" name="sports[]" value="0">足球<br>
<input type="checkbox" name="sports[]" value="10">篮球<br>
<input type="checkbox" name="sports[]" value="20">排球<br>
<input type="checkbox" name="sports[]" value="30">乒乓球<br>
<input type="checkbox" name="sports[]" value="40">羽毛球<br>
<input type="checkbox" name="sports[]" value="50">橄榄球<br>
<input type="checkbox" name="sports[]" value="60">冰球<br>
<input type="checkbox" name="sports[]" value="70">曲棍球<br>
<input type="checkbox" name="sports[]" value="80">同求<br><br>
<input type="checkbox" id="chkAll" onclick="chkAll(this)">全选
<script type="text/javascript">
var objs = document.getElementsByName('sports[]')
function chkAll(obj){
for (var i = objs.length - 1 i >= 0 i--) {
objs[i].checked = obj.checked
}
}
</script>
</body>
</html>
function select_all(){var inputs = document.getElementsByTagName('input')
for(var i=0i<inputs.lengthi++)
{
if(inputs[i].getAttribute('type')=='checkbox')
{
inputs[i].checked = true
}
}
}
function reverse_select_all(){
var inputs = document.getElementsByTagName('input')
for(var i=0i<inputs.lengthi++)
{
if(inputs[i].getAttribute('type')=='checkbox')
{
if (inputs[i].checked == true){
inputs[i].checked = false
}else{
inputs[i].checked = true
}
}
}
}
function selectAll1(MENU_ALL,QIANZHUI,NUMBER)//全选名称或id,前缀,个数
{
for(var i=1i<=NUMBERi++)
{
var bba=QIANZHUI+"_"+i
var bba1=document.getElementById(MENU_ALL)
if(bba1.checked)
document.getElementById(bba).checked=true
else
document.getElementById(bba).checked=false
}
}
function selectAll2(MENU_ALL,QIANZHUI,NUMBER,NUMBER1)//全选名称或id,前缀,开始位置,结束位置
{
for(var i=NUMBER1+1i<=NUMBERi++)
{
var bba=QIANZHUI+"_"+i
var bba1=document.getElementById(MENU_ALL)
if(bba1.checked)
document.getElementById(bba).checked=true
else
document.getElementById(bba).checked=false
}
}
<!DOCTYPE html><html>
<head>
<title></title>
</head>
<body>
<div>文本框:</div>
<textarea>按下ESC选中我</textarea>
<script src="jquery.min.js" ></script>
<script type="text/javascript">
function hotkey()
{
var a=window.event.keyCode
if(a==27)
{
$('textarea').select()
}
}
// 初始化加载
$(document).ready(function () {
document.onkeydown = hotkey
})
</script>
</body>
</html>