我有以下jquery,如果复选框被选中,它允许用户在表单中填写额外的字段。我想要的是如果复选框未选中,则清除附加输入字段的值。
$(document).ready(function() {
$('input:checkbox').attr('checked', false);
$('#xml').hide();
$('#checkbox').click(function() {
$('#xml')[this.checked ? "show" : "hide"]();
});
$('input[type="checkbox"]').click(function() {
if (this.checked) {
$('div#xml p label input').attr('required', true);
}
else
$('div#xml p label input').removeAttr('required', true);
//Here should the corresponding code to be pasted
//$('div#xml p label input').val = ('');
});
$(function() {
$("#datepicker").datepicker();
});
});
https://stackoverflow.com/questions/9939247
复制相似问题