【发布时间】:2014-01-10 16:16:05
【问题描述】:
当屏幕加载和更改其中一个文本框时,我有一些禁用的复选框,复选框会自动选中,我希望在表单提交期间将复选框值提交给我的支持 bean,因此我将 onclick 函数附加到通过 Jquery 提交按钮以在提交时启用复选框,但仍然没有提交值,但是如果我直接向提交按钮的 onclick 添加一个 javascript 函数,则值会被提交。
我的代码是这样的
<input type="checkbox" id="chck_box1" class="enableCheckbox"/>
<input type="submit" id="submitButton" onclick="enableCheckBox()"/>
there are two ways i implemented
**1.** --- this enables the checkbox and values submitted
function enableCheckbox(){
$('.enableCheckbox').each(function() {
$(this).removeAttr('disabled');
});
}
**2.** -- this enables the checkbox but the values not submitted
$("#submitButton").on("click", function(){
$('.enableCheckbox').each(function() {
$(this).removeAttr('disabled');
});
});
谁能帮我理解提交按钮 onclick 和 jquery 的 on(submit) 之间的区别
谢谢
【问题讨论】:
-
提示:
$(this).prop('disabled', false);. -
能否也发布您的 HTML 表单标记?
-
我确实尝试了该道具,但这也无济于事..问题是 removeAttr 或道具在提交时从 javascript 函数调用而不是动态绑定时起作用... 这个 enableCheckBox 函数有我上面帖子中的代码..