admin管理员组文章数量:1295277
I want to popup a jQuery dialog when a html checkbox is checked. I'm using following code. But it's not working.
$(document).ready(function () {
$('#chkBoxHelp').click(function () {
if ($(this).is(':checked')) {
$("#txtAge").dialog();
}
});
});
And the html is as below:
<input type="checkbox" id="chkBoxHelp"/>
<div id="txtAge" style="display: none;">Age is something</div>
Please help me.
Also I want to uncheck the checkBox when popup will be closed. Checkbox is in a jQuery popup box. I need to open another popup on checkbox checked.
Thanks in Advance.
I want to popup a jQuery dialog when a html checkbox is checked. I'm using following code. But it's not working.
$(document).ready(function () {
$('#chkBoxHelp').click(function () {
if ($(this).is(':checked')) {
$("#txtAge").dialog();
}
});
});
And the html is as below:
<input type="checkbox" id="chkBoxHelp"/>
<div id="txtAge" style="display: none;">Age is something</div>
Please help me.
Also I want to uncheck the checkBox when popup will be closed. Checkbox is in a jQuery popup box. I need to open another popup on checkbox checked.
Thanks in Advance.
Share edited Oct 4, 2013 at 14:31 asked Oct 4, 2013 at 12:50 user1527336user1527336 2- Here you go -> jsfiddle/x4CM3/1 – adeneo Commented Oct 4, 2013 at 12:55
- Hi Adeneo, thanks for your response. It's working fine in asp page. I forget to mention that the checkbox is in a jQuery popup. I need to open another popup on checkbox checked. I've also updated the question. Please help. – user1527336 Commented Oct 4, 2013 at 14:33
2 Answers
Reset to default 3You can use open
and close
methods and close
event.
Code:
$(document).ready(function () {
$('#chkBoxHelp').click(function () {
if ($(this).is(':checked')) {
$("#txtAge").dialog({
close: function () {
$('#chkBoxHelp').prop('checked', false);
}
});
} else {
$("#txtAge").dialog('close');
}
});
});
Demo: http://jsfiddle/IrvinDominin/V9zMx/
Try this, also closing if the checkbox is clicked again.
$(document).ready(function () {
var the_checkbox = $('#chkBoxHelp');
the_checkbox.click(function () {
if ($(this).is(':checked')) {
$("#txtAge").dialog({
close: function () {
the_checkbox.prop('checked', false);
}
});
} else {
$("#txtAge").dialog('close');
}
});
});
Demo here
本文标签: javascriptHow to open jQuery dialog on html CheckBox checked(using jQuery)Stack Overflow
版权声明:本文标题:javascript - How to open jQuery dialog on html CheckBox checked(using jQuery)? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741616029a2388531.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论