Skip to content

Instantly share code, notes, and snippets.

@MilanGrubnic70
Last active August 29, 2015 14:02
Show Gist options
  • Save MilanGrubnic70/4e219d1844070ea46b9a to your computer and use it in GitHub Desktop.
Save MilanGrubnic70/4e219d1844070ea46b9a to your computer and use it in GitHub Desktop.
mac3
$(document).ready(function(){
$('#get_color').click(function(event){
event.preventDefault();
$.post('/color', function(response){
$("#color_me li:nth-child(" + response.cell +")").css( "background-color", response.color );
}, 'json');
});
});
post '/color' do
#Create and return a JSON object with the random cell and color given below.
cell= rand(1..9)
color= "#" + "%06x" % (rand * 0xffffff)
{cell: cell, color: color}.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment