php - Disable inputs with jquery by default -


i want disable default inputs, , have check box allows enable them; code of checkbox :

function togglestatus() {   if ($('#toggleelement').is(':checked')) {     $('#elementstooperateon :input').attr('disabled', true);   }    else {     $('#elementstooperateon :input').removeattr('disabled');   } } 

and it's called in input onchange="togglestatus()"; default status of inputs enabled , don't want add disabled="disabled" each input, how can jquery? , how can make work existing onchange?

$(function(){     $('#elementstooperateon :input').prop('disabled', true); }); 

disable inputs when dom ready.

o.k. after update, answer simpler, trigger onchange event:

either with:

togglestatus(); 

or with

$('#toggleelement').change(); 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -