javascript - Disable and reset or empty all inputs -


i'm trying disable every type of input on page , uncheck or empty values, i've written following code:-

function disableall() {                   if ($('#chkloginenabled').is(':checked')) {                       $("input").attr("disabled", false);                   }                   else {                       $("input").attr("disabled", true);                       $("input checkbox").attr('checked') = 'checked';                       $("input textbox").val() = "";                    }                   $("#chkloginenabled").attr("disabled", false);                 } 

it works disable inputs (and correctly re-enables 1 need),

however, doesn't reset of inputs.

try

function disableall() {     var inputs = $('input');     if ($('#chkloginenabled').is(':checked')) {         inputs.prop('disabled', false);     } else {         inputs.prop('disabled', true);         inputs.filter('[type="checkbox"]').prop('checked', false)         inputs.filter(':text').val('')     }     $('#chkloginenabled').attr('disabled', false); } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -