js复选框选中显示隐藏的div
functionreceiptChecked(){varcheckbox=document.getElementById("receiptchk");if(checkbo...
function receiptChecked() {
var checkbox = document.getElementById("receiptchk");
if(checkbox.checked) {
document.getElementById("receiptStartd").style.display="";
document.getElementById("receiptEnd").style.display="";
}
else
document.getElementById("receiptStartd").style.display="none";
document.getElementById("receiptEnd").style.display="none";
}
<div>
<label>回执:</label>
<input type="checkbox" id="receiptchk" name="receiptchk" onclick="receiptChecked()" value=""/>
</div>
<div id="receiptStart" class="field" style="width:100%;display:none">
#{field "announcement.receiptStart"}
<label for="${field.id}">回执开始时间</label>
<input type="text" id="${field.id}" name="${field.name}" readonly="readonly" class="txt01 Wdate ${field.errorClass}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="${field.value?.format('yyyy-MM-dd')}" />
<span class="error">${field.error}</span>
#{/field}
</div>
<div id="receiptEnd" class="field" style="width:100%;display:none">
#{field "announcement.receiptEnd"}
<label for="${field.id}">回执结束时间</label>
<input type="text" id="${field.id}" name="${field.name}" readonly="readonly" class="txt01 Wdate ${field.errorClass}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="${field.value?.format('yyyy-MM-dd')}" />
<span class="error">${field.error}</span>
#{/field}
</div>
有语法错误么?为什么没有效果 展开
var checkbox = document.getElementById("receiptchk");
if(checkbox.checked) {
document.getElementById("receiptStartd").style.display="";
document.getElementById("receiptEnd").style.display="";
}
else
document.getElementById("receiptStartd").style.display="none";
document.getElementById("receiptEnd").style.display="none";
}
<div>
<label>回执:</label>
<input type="checkbox" id="receiptchk" name="receiptchk" onclick="receiptChecked()" value=""/>
</div>
<div id="receiptStart" class="field" style="width:100%;display:none">
#{field "announcement.receiptStart"}
<label for="${field.id}">回执开始时间</label>
<input type="text" id="${field.id}" name="${field.name}" readonly="readonly" class="txt01 Wdate ${field.errorClass}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="${field.value?.format('yyyy-MM-dd')}" />
<span class="error">${field.error}</span>
#{/field}
</div>
<div id="receiptEnd" class="field" style="width:100%;display:none">
#{field "announcement.receiptEnd"}
<label for="${field.id}">回执结束时间</label>
<input type="text" id="${field.id}" name="${field.name}" readonly="readonly" class="txt01 Wdate ${field.errorClass}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" value="${field.value?.format('yyyy-MM-dd')}" />
<span class="error">${field.error}</span>
#{/field}
</div>
有语法错误么?为什么没有效果 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询