请问问什么这种方法不行
<input type="button" id="btn1" value = "全选" >
<input type="button" id="btn2" value = "全不选" >
<p>请输入您要选择爱好的序号,序号为1-6:</p>
<input id="wb" name="wb" type="text" >
<input name="ok" type="button" value="确定" onclick = "checkone();">
</form>
<script type="text/javascript">
window.onload = function(){
var btn1 = document.getElementById("btn1");
var btn2 = document.getElementById("btn2");
var hobby = document.getElementsByName("hobby");
for(var i=0;i<=hobby.length;i++){
btn1.onclick = function{
hobby[i].checked=true;
}
btn2.onclick = function{
hobby[i].checked=false;
}
}
// 任务1
}