Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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