Skip to content

Instantly share code, notes, and snippets.

@kierarad
Created October 9, 2013 03:12
Show Gist options
  • Save kierarad/6895627 to your computer and use it in GitHub Desktop.
Save kierarad/6895627 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('#roller button.add').on('click', function() {
console.log("WAT")
$('.dice').append('<div class="die">0</div>');
});
$('#roller button.roll').on('click', function() {
$('.die').each(function(k, die) {
var value = Math.floor((Math.random()*6)+1);
$(die).text(value);
});
});
});
document.onready(function{
addButton = document.querySelector('#roller button.add');
bindListeners(addButton, onclick, addNewDice);
});
function BindListeners (element, eventType, callback){
element.addEventListener(eventType, callback, false);
};
function addNewDice(){
getDice();
};
function getDice(){
document.querySelector('.dice');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment