document.getElementById不起作用

use*_*408 2 javascript client-side

我在页面上有2个chekboxes.每个行都包含在一个表格单元格中.执行document.getElementById('chk1_FEAS~1005')会返回元素,但document.getElementById('chk5_STG2~1005')为空.出于什么原因可能会发生这种情况?(我在IE 8中测试).

<input id="chk1_FEAS~1005" value="JobStages###StageCode~JobCode###FEAS~1005" onclick="addRemoveRow(this.value,this.checked)" style="border-width:0px;padding:1px;margin:0px;height:14px;"  type="checkbox" />

<input id="chk5_STG2~1005" value="JobStages###StageCode~JobCode###STG2~1005" onclick="addRemoveRow(this.value,this.checked)" style="border-width:0px;padding:1px;margin:0px;height:14px;"  type="checkbox" />
Run Code Online (Sandbox Code Playgroud)

CMS*_*CMS 10

您的ID包含无效字符:

ID和NAME令牌必须以字母([A-Za-z])开头,后面可以跟任意数量的字母,数字([0-9]),连字符(" - "),下划线("_") ,冒号(":")和句号(".").

更多信息在这里.