Skip to content

Instantly share code, notes, and snippets.

@MarcosBL
Created September 25, 2014 00:43
Show Gist options
  • Select an option

  • Save MarcosBL/5d007189a7ed51ffb871 to your computer and use it in GitHub Desktop.

Select an option

Save MarcosBL/5d007189a7ed51ffb871 to your computer and use it in GitHub Desktop.
setInterval(function () {
var change = {};
$('#box span').each(function () {
var $this = $(this),
key = $this.css('background-color');
if (!(key in change)) {
change[key] = {
'element': $this,
'count': 0
};
}
change[key]['count']++;
});
if (change.length === 0) {
return;
}
$.each(change, function (index, element) {
if (element['count'] === 1) {
element['element'].trigger('click');
}
});
}, 50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment