Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AndryWJ/f0422b3813118aefd221f8c864e80f54 to your computer and use it in GitHub Desktop.
Save AndryWJ/f0422b3813118aefd221f8c864e80f54 to your computer and use it in GitHub Desktop.
JS: неактивная кнопка в зависимости от чекбокса
$('.formLine-form input[type="checkbox"]').change(function(event) {
testCheckPolit($(this));
});
// Если чекбокс выбран то активируем кнопку отправки если нет деактивируем
function testCheckPolit(el){
if(el.prop('checked')){
el.closest('form').find('button, input[type="submit"]').removeAttr('disabled');
}else {
el.closest('form').find('button, input[type="submit"]').attr('disabled', 'disabled');
}
}
// css
button[disabled="disabled"],
input[disabled="disabled"]{
background: #8796a6 !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment