function safe(){
if($(this).is(':checked')){
$("select[name='sort']").attr("disabled", "disabled");
$("input[name='group']").attr("disabled", "disabled")
} else {
$("select[name='sort']").attr("disabled", false);
$("input[name='group']").attr("disabled", false)
}
}
$('input#safe').change(failsafe);
I have this function that I want to run onLoad as well as onChange, at the same time. Currently only onChange works, but onLoad, those fields remain enabled.
Thanks for your help!
Not entirely sure if this is what you’re looking for, but if you were hoping to run the
safe()code when the page loads, try this.Example: http://jsfiddle.net/ewNEc/
Uses
.triggerHandler()to fire the handler without changing the state.