嗨, 我想创建一个简单的函数来重置所有输入值而无需目标输入。 我不知道我该怎么做。 谢谢。我想创建一个简单的函数来重置没有目标输入的所有输入值。 (Javascript,Jquery)
编辑:该函数重置所有的输入值。我需要保存/捕获目标值。
这里是我的示例代码:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function reset_other_inputs(room) {
$("input[name^='check_in_date_']").each(function() {
if ($("input[name!='check_in_date_'+room]")) { $(this).val(""); }
});
$("input[name^='check_out_date_']").each(function() {
if ($("input[name!='check_out_date_'+room]")) { $(this).val(""); }
});
}
</script>
<input type="text" name="check_in_date_single" value="single" onClick="reset_other_inputs('single');">
<input type="text" name="check_out_date_single" value="single" onClick="reset_other_inputs('single');">
<input type="text" name="check_in_date_double" value="double" onClick="reset_other_inputs('double');">
<input type="text" name="check_out_date_double" value="double" onClick="reset_other_inputs('double');">
<input type="text" name="check_in_date_triple" value="triple" onClick="reset_other_inputs('triple');">
<input type="text" name="check_out_date_triple" value="triple" onClick="reset_other_inputs('triple');">
<input type="text" name="check_in_date_suite" value="suite" onClick="reset_other_inputs('suite');">
<input type="text" name="check_out_date_suite" value="suite" onClick="reset_other_inputs('suite');">
那么,什么样的代码部分不起作用,是什么问题? – 2010-05-09 13:53:43
该功能不起作用,我无法修复该问题。 – 2010-05-09 13:55:21
该函数重置所有输入值。我需要保存/捕获目标值。 – 2010-05-09 14:36:16