试试这个:http: //jsfiddle.net/96FJp/
用户界面:
<form id="thisForm">
<input type="text" value="HellO">
<input type="text" value="World">
<input type="button" value="wow"/>
</form>
<input type="button" id="test">
jQuery:
$('#test').click(function() {
$('input:not([type=button])', '#thisForm').val('');
});
<hr/> 要包含其他输入,只需在 jQuery 选择器上加一个逗号,执行以下操作:http: //jsfiddle.net/dpRJy/1/
用户界面:
<form id="thisForm">
<input type="text" value="HellO">
<input type="text" value="World">
<input type="button" value="wow"/>
<select id="country">
<option value="">--Select Country--</option>
<option value="PH">Philippines</option>
<option value="CN" selected>China</option>
<option value="CA">Canada</option>
</select>
<br/>
<input id="drink" type="radio" name="drink" value="Water"> Water<br>
<input id="drink" type="radio" name="drink" value="Beer"> Beer<br>
<input id="drink" type="radio" name="drink" value="Wine" checked>Wine<br/>
</form>
<input type="button" id="test">
jQuery:
$('#test').click(function() {
$('input:not([type=button]),select', '#thisForm').val('');
// radio button doesn't fit nicely to method val value clearing,
// have to do this:
$('input:radio','#thisForm').prop('checked', false);
});