如果在弹出 div 内单击,我希望弹出 div 保持打开状态,因为它包含要由用户填写的表单。这是我的代码
Javascript:
<script>
$('#btnFieldWorkers').bind("click", ToggleDisplay);
function ToggleDisplay() {
if ($("#div_fieldWorkers").data('shown')) {
hide();
}
else
display();
}
function display() {
if ($("#div_fieldWorkers").children().length > 0) {
$("#div_fieldWorkers").fadeIn(300, function () {
$(document).bind("click", function () { hide(); });
$("#div_fieldWorkers").data('shown', true)
});
}
}
function hide() {
$("#div_fieldWorkers").fadeOut(300, function () {
$(document).unbind("click");
$("#div_fieldWorkers").data('shown', false);
});
}
</script>
HTML:
<input type="button" value="Add Field Worker" id="btnFieldWorkers" onclick="return ToggleDisplay();" class="btn btn-primary" />
<div id="div_fieldWorkers" style="display:none;" class="form_size"></div>