Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save DaWe35/9af01eea8ffd18b724d791b9f127efb0 to your computer and use it in GitHub Desktop.
Save DaWe35/9af01eea8ffd18b724d791b9f127efb0 to your computer and use it in GitHub Desktop.
<script>
jQuery(document).ready(function($) {
function checkFunction(color) {
console.log(color);
var x = $("li." + color);
var exists = false;
for (var i = 0; i < x.length; i++) {
if($(x[i]).hasClass("active")) {
exists = true;
}
}
if (exists) {
for (i = 0; i < x.length; i++) {
$(x[i]).children("button").attr('disabled', 'disabled');
}
} else {
for (i = 0; i < x.length; i++) {
$(x[i]).children("button").removeAttr('disabled');
}
}
}
function checkAll() {
checkFunction('color-yellow');
checkFunction('color-black');
checkFunction('color-red');
checkFunction('color-natural');
checkFunction('color-green');
checkFunction('color-blue');
}
$(document).on('click', '.choice-item', checkAll);
$( document ).ready(function() {
checkAll();
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment