document.getElementById not working

断了今生、忘了曾经 提交于 2019-12-06 09:37:08

Your Id has invalid characters:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

More information here.

aehlke
document.getElementById('hk5_STG2~1005') 

should be

document.getElementById('chk5_STG2~1005') 

:-)

Looking at your sample it is a typo, the second item should be, document.getElementById('chk5_STG2~1005')

Also, I would recommend removing the ~ character as it is invalid for an id.

For what it's worth, I have similar problems using document.getElementById on checkboxes in IE8. Try adding this tag to your head section :-

<meta http-equiv="X-UA-Compatible" content="IE=7" />

This will force IE8 into IE7 compatibility mode. It works for me as a workaround until I find-out what's really up.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!