Skip to content

Instantly share code, notes, and snippets.

@e-river
Last active February 14, 2017 07:14
Show Gist options
  • Save e-river/ffc4017714b03e0d8f3d495b91261ae4 to your computer and use it in GitHub Desktop.
Save e-river/ffc4017714b03e0d8f3d495b91261ae4 to your computer and use it in GitHub Desktop.
document.addEventListener("DOMContentLoaded", function(event) {
new ShowButton().load();
});
function ShowButton() {
this.btn = document.querySelectorAll('.class');
this.target = document.querySelectorAll('input[type="checkbox"]');
}
ShowButton.prototype.load = function() {
var self = this;
for(var i = 0; i < self.target.length; i++){
self.target[i].addEventListener('change', function(){
self.event();
}, null);
}
};
ShowButton.prototype.event = function() {
var self = this;
var checkCount = 0;
for(var i = 0; i < self.target.length; i++) {
if(self.target[i].checked) {
checkCount ++;
}
if(checkCount === 0) {
self.btn[0].style.opacity = 0;
} else {
self.btn[0].style.opacity = 1;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment