<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>
<!DOCTYPE html><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>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
//全选
function test()
{
var f=document.getElementsByName("game")
for(var i=0i<f.lengthi++)
{
if(f[i].checked==false)
{
f[i].checked=true
}
}
}
//反选
function ftest()
{
var f=document.getElementsByName("game")
for( var i=0i<f.lengthi++)
{
if(f[i].checked==false)
{
f[i].checked=true
}
else
{
f[i].checked=false
}
}
}
//全部取消
function CancelAll()
{
var f=document.getElementsByName("game")
for( var i=0i<f.lengthi++)
{
if(f[i].checked==true)
{
f[i].checked=false
}
}
}
</script>
</head>
<body>
<input name="game" type="checkbox" value="lanqiu"/>篮球
<input name="game" type="checkbox" value="zuqiu"/>足球
<input name="game" type="checkbox" value="pingpangqiu"/>乒乓球
<input name="game" type="checkbox" value="bangqiu"/>棒球
<input name="game" type="checkbox" value="ganlanqiu"/>橄榄球<br/>
<input type="button" value="全选" onclick="test()"/>
<input type="button" value="反选" onclick="ftest()"/>
<input type="button" value="全不选" onclick="CancelAll()"/>
</body>
</html>
把if(f[i].checked=true) 改为 if(f[i].checked==true)