Skip to content

Instantly share code, notes, and snippets.

@e-river e-river/checkinput.js
Last active Feb 14, 2017

Embed
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.