Not quite sure if this is what you are looking for, but if you were hoping to run the code safe()when the page loads, try this.
Example: http://jsfiddle.net/ewNEc/
$(function() {
function safe(){
if( this.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(safe).triggerHandler("change");
});
Used .triggerHandler()to start a handler without changing state.
source
share