工作,我写了下面的脚本检查时改变复选框的背景色,但是这是不工作的Mozila为什么我的JavaScript未在Firefox
<script type="text/javascript">
function checkBoxList1OnCheck(listControlRef)
{
var inputItemArray = listControlRef.getElementsByTagName('input');
for (var i=0; i<inputItemArray.length; i++)
{
var inputItem = inputItemArray[i];
if (inputItem.checked)
{
inputItem.parentElement.style.backgroundColor = 'Red';
}
else
{
inputItem.parentElement.style.backgroundColor = 'White';
}
}
}
</script>
<form id="form1" runat="server">
<div>
<asp:CheckBoxList id="CheckBoxList1" onclick="checkBoxList1OnCheck(this);" runat="server">
<asp:listitem value="1">Item 1</asp:listitem>
<asp:listitem value="2">Item 2</asp:listitem>
<asp:listitem value="3">Item 3</asp:listitem>
</asp:CheckBoxList>
</div>
</form>
,甚至在页面加载我添加如下
CheckBoxList1.Attributes.Add("onclick", "checkBoxList1OnCheck(this);");
但是还是我无法做出来的Mozila任何一个可以帮助我
究竟是不是工作?你会得到什么错误? –
是不是在IE或Mozilla中工作? – rid
我没有收到任何错误我无法得到我需要的输出 – Dotnet