Last active
July 7, 2017 07:15
-
-
Save Pum-purum/1ad6b60141d2c094c78691a95379c4ad to your computer and use it in GitHub Desktop.
Checker - активация кнопки при нажатии на галочку
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* функция вида 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