javascript - Change attr to class with jquery -



javascript - Change attr to class with jquery -

i have script:

$(document).ready(function() { $('#checkout1').addclass('disabled'); $('#voorwaarden').change(function() { $('#checkout1').attr('disabled', $(this).is(':checked') ? null : 'disabled'); }); });

the script no alter attr disabled. how can alter script thing. when alter #voorwaarden. remove class diabled #checkout1. , when changed next #voorwaarden. add together class , going furter , furter. #voorwaarden checkbox.

thanks!

simply toggleclass()

$(document).ready(function() { $('#checkout1').addclass('disabled'); $('#voorwaarden').change(function() { $('#checkout1').toggleclass('disabled'); }); });

note: http://api.jquery.com/toggleclass/

edited: in case want toggle 'disabled' property,

$(document).ready(function() { $('#checkout1').prop('disabled', true); $('#voorwaarden').change(function() { $('#checkout1').prop('disabled', !$('#checkout1').prop('disabled')); }); });

javascript jquery addclass

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -