cheked在复选框上打开一个弹出窗口
问题描述:
你好,
我想在选中复选框时打开一个弹出窗口,当我们关闭弹出复选框时自动取消选中,还有一件事我想要在弹出窗口中添加一个保存按钮。
我正在使用以下代码。但它没有用。
Hello,
I want to open a popup when a check-box is checked and when we close the popup check-box automatically unchecked and one more thing i want to add a save button in popup.
I am using following code. But it is not working.
$(document).ready(function () {
var the_checkbox = $('#chkBoxHelp');
the_checkbox.click(function () {
if ($(this).is(':checked')) {
$("#txtPopup").dialog({
close: function () {
the_checkbox.prop('checked', false);
}
});
} else {
$("#txtPopup").dialog('close');
}
});
});
并且html如下:
And the html is as below:
<input type="checkbox" id="chkBoxHelp"/>
<div id="txtPopup" style="display: none;">hello! It is a popup</div>
但我不知道为什么这不起作用。
But I don't know why this is not work.
答
(document).ready(function(){
var the_checkbox =
(document).ready(function () { var the_checkbox =
('#chkBoxHelp');
the_checkbox .click(function(){
if(
('#chkBoxHelp'); the_checkbox.click(function () { if (
(this).is(':checked')){
(this).is(':checked')) {