单击“取消”按钮后清除选中的复选框
clear checked check box after clicking cancel button
html:
<div id="member_form" style="display:none">
<form id="contactform" method="post" action="." onsubmit="if($('input[name=name]').is(':checked')){return true;}else{$('#choose_warning').show();return false}">
{% csrf_token %}
<h2> Choose Person</h2>
<br />
{% if contact_list %}
{%for contact in contact_list%}
<input type="radio" name="name" id="contact" value="{{contact.first_name}} {{contact.last_name}}" maxlength="30" />
{{contact.first_name|title}} {{contact.last_name}}<br />
{% endfor %}
<input type="hidden" name="action_type" value="" id="member_action_type" maxlength="30" />
<p style="display:none;color:red" id="choose_warning">Please choose a contact.</p>
<div style="width:180px;margin:20px 5px 0 10px" align="left">
<button style="margin-right:10px;" type="button" class="close" name="cancel" class="forward backicon">
<img src="{{ STATIC_URL }}images/button-icon-ir-back.png" width="12" height="17" alt="" />
Cancel</button> {% include "buttons/add.html" %}
</div></form>
.js:
$(document).ready(function(){
$(".add_list").click(function(){
'''''''
$("#member_form").fadeIn(1000);
});
$(".close").click(function(){
$("#member_form").fadeOut(500);
});
});
我的问题是如果我选择一个单选按钮并按取消,如果我打开弹出窗口而不刷新,所选单选按钮处于选中模式,我希望它清晰,如果我单击取消按钮并打开弹出窗口,如何在这里做。
现在它清除所有无线电:
$(".close").click(function(){
$("input:radio").prop("checked", false);
$("#member_form").fadeOut(500);
});
只需将此代码用于查询即可根据您的使用情况编辑按钮的名称。它会正常工作。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Check/Uncheck Radio Button</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".check-male").click(function(){
$("#male").prop("checked", true);
});
$(".check-female").click(function(){
$("#female").prop("checked", true);
});
$(".cancel").click(function(){
$("#female").prop("checked", false);
$("#male").prop("checked", false);
});
});
</script>
</head>
<body>
<label><input type="radio" name="gender" id="male"> Male</label>
<label><input type="radio" name="gender" id="female"> Female</label>
<button type="button" class="cancel">Cancel</button>
<p><strong>Note:</strong> Click the cancel uncheck radio button.</p>
</body>
</html>
相关文章:
- 选中复选框时清除填充有datatime选取器数据的文本框
- 选中此之后剩余的复选框值.form.reset清除
- 使用 onChange 清除多个选择和复选框
- 如何使用Javascript清除基于复选框的文本框
- 清除“选中的复选框范围”值
- 取消选中复选框时隐藏和清除文本框
- jQuery UI 多选小部件清除所有复选框
- 无法清除 Jquery 中的所有复选框
- 如何在下次尝试之前从复选框中清除旧值
- jQuery清除日期选择器字段中的值,该值与未选中的复选框相关联
- 如何使用复选框取消选中来清除单选按钮
- 清除复选框按钮不起作用
- 更改单选按钮选择时清除复选框
- 如何使用javascript清除所有项目并在asp.net复选框列表中添加新项目
- 如何使用javascript保护用户清除复选框
- 如何清除复选框当选中其他复选框时?使用java脚本
- 单击“取消”按钮后清除选中的复选框
- 当标记/清除复选框时,引导复选框标签上的工具提示不会隐藏
- 切换融合表层:如何在选中新复选框时清除所有其他复选框
- 使用复选框清除表单