<
html
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>全选和反选</
title
>
</
head
>
<
body
>
<
input
type
=
"button"
value
=
"全选"
>
<
script
type
=
"text/javascript"
>
var input=document.getElementByTagName("input")[0];
input.onclick=function(){
if(this.value=="全选"){
this.value="反选";
}else {
this.value="全选";
}
}//补充代码
</
script
>
</
body
>
</
html
>
input=document.getElementByTagName("input")
tagname不是唯一的,所以取出来是个数组,document.getElementsByTagName()
要加s
因为是数组所以有数组的属性,如果要取当前的要用document.getElementsByTagName('input')[0]