Skip to content

Instantly share code, notes, and snippets.

@Pum-purum
Last active July 7, 2017 07:15
Show Gist options
  • Save Pum-purum/1ad6b60141d2c094c78691a95379c4ad to your computer and use it in GitHub Desktop.
Save Pum-purum/1ad6b60141d2c094c78691a95379c4ad to your computer and use it in GitHub Desktop.
Checker - активация кнопки при нажатии на галочку
/**
* функция вида checker("#checkbox_1", "#web_form_apply");
* где checkbox_1 - селектор чекбокса,
* web_form_apply - селектор кнопки, которая д.б. неактивна при выключенном чекбоксе
*/
var checker = function (checkbox_id, button_id) {
if (!$(checkbox_id).is(":checked")) {
$(button_id).attr("disabled", true).css({opacity: "0.3"});
}
$(checkbox_id).change(function () {
if ($(this).is(":checked")) {
$(button_id).attr("disabled", false).css({opacity: "1"});
}
else {
$(button_id).attr("disabled", true).css({opacity: "0.3"});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment