Last active
February 14, 2017 07:14
-
-
Save e-river/ffc4017714b03e0d8f3d495b91261ae4 to your computer and use it in GitHub Desktop.
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
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