Skip to content

Instantly share code, notes, and snippets.

View jensechu's full-sized avatar

Jensen Kuras jensechu

View GitHub Profile
$(document).ready(function(){
var furs = ["#FFFFFF", "#F7941D", "#EBEBEB", "#636363", "#C69C6D", "#A186BE", "395A00", "#FFF220"];
$("#picture img").click(function () {
var choice = Math.floor(Math.random()*furs.length);
$(this).css({ "background-color" : furs[choice] });
});
$(document).ready(function(){
var furs = ["#FFFFFF", "#F7941D", "#EBEBEB", "#636363", "#C69C6D", "#A186BE", "395A00", "#FFF220"];
$("#picture img").click(function () {
var choice = Math.floor(Math.random()*furs.length);
$(this).css({ "background-color" : furs[choice] });
});
$(document).ready(function(){
var furs = ["#FFFFFF", "#F7941D", "#EBEBEB", "#636363", "#C69C6D", "#A186BE", "395A00", "#FFF220"];
$("#picture img").click(function () {
var choice = Math.floor(Math.random()*furs.length);
$(this).css({ "background-color" : furs[choice] });
});
<div id="picture">
<img src="images/kitty.png"></img>
</div>
<div id="food">
<p>nom nom nom</p>
<img src="images/nomnom.png"></img>
<img class="fish" src="images/fish.png"></img>
</div>
$("#picture img").droppable({
drop: function() {
$(this).attr({ src: "images/kitty_nom.png" });
$(this).addClass("eating");
$(".fish").hide();
}
});
$(".fish").draggable({
drag: function() {
$("#picture img").attr({ src: "images/kitty_hungry.png" });
revert: true;
},
stop: function () {
if($("#picture img").hasClass("eating")) {
setTimeout(reset_kitty, 2000);
}
else {
$(".fish").draggable({
drag: function() {
$("#picture img").attr({ src: "images/kitty_hungry.png" });
revert: true;
},
stop: function () {
if($("#picture img").hasClass("eating")) {
setTimeout(reset_kitty, 2000);
}
else {
var fishLeft = $('.fish').css('left');
var fishTop = $('.fish').css('top');
function reset_kitty() {
$("#picture img").attr({ src: "images/kitty.png" });
$("#picture img").removeClass("eating");
$('.fish').css({top: fishTop,
left: fishLeft});
$('.fish').fadeIn("slow");
<div id="talk">
<form>
<p>mrow</p>
<input type="text" name="rawr" id="user-input" size="10" maxlength="10" />
<input type="submit" name="chat" value="meow" class="subby" />
<h4>max 10 characters</h4>
</form>
</div>