HTML:
<form>
<button type="button" class="form-clear">Clear</button>
<button type="button" class="form-set">Set</button>
<input type="text" value="Preset value" />
<input type="checkbox" checked/>
<input type="checkbox" />
</form>
jQuery:
$(".form-clear").click(function(){
$(':input').not(':button, :submit, :reset, :hidden').val('');
$(':checkbox, :radio').attr('checked', false);
});
$(".form-set").click(function(){
$(':input').not(':button, :submit, :reset, :hidden').val('New preset value');
$(':checkbox, :radio').attr('checked', true);
});
- Click Set first. This will input "New preset value" and check the second checkbox.
- Click Clear to clear the whole form.
- Click Set again. This will input "New preset value" but will not check the second checkbox.
I'm guessing there's a conflict between the two functions?