Last active
August 29, 2015 14:02
-
-
Save MilanGrubnic70/4e219d1844070ea46b9a to your computer and use it in GitHub Desktop.
mac3
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).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