我有一个页面,我希望将几个复选框默认设置为禁用,但可以通过 JavaScript 启用。当我查看页面源代码时,复选框上的 HTML 如下所示:
<input type="checkbox" id="morning1" name="morning[]" class="morning" value="1" disabled="disabled" />
但是,这些框实际上已启用。更重要的是,当我在 Firebug 中检查它们时,禁用的属性甚至都没有出现。知道这里发生了什么吗?我的初始 HTML 代码是否存在某种缺陷?
好的,这是我的页面为整个表格单元格的内容生成的内容:
<span class="dayOfWeek">1</span>
<div class="cellContent"><input type="checkbox" id="allDay1" name=allDay[] class="allDay" value="1" checked="checked" /> <label for="allDay1">All Day</label><br />
<input type="checkbox" id="morning1" name="morning[]" class="morning" value="1" disabled="disabled" /> <label for="morning1">Morning</label><br />
<input type="checkbox" id="afternoon1" name="afternoon[]" class="afternoon" value="1" disabled="disabled" /> <label for="afternoon1">Afternoon</label><br />
<input type="checkbox" id="evening1" name="evening[]" class="evening" value="1" disabled="disabled" /> <label for="evening1">Evening</label><br />
<input type="checkbox" id="swingShift1" name="swingShift[]" class="swingShift" value="1" disabled="disabled" /> <label for="swingShift1">Swing Shift</label><br />
<input type="checkbox" id="earlyMorning1" name="earlyMorning[]" class="earlyMorning" value="1" disabled="disabled" /> <label for="earlyMorning1">Early Morning</label></div>