Created
October 22, 2014 23:01
-
-
Save katherineschultz/e785dff12f0ac8cf61e7 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/deboti
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<a href="#" onClick="calculate()">Calculate It</a> | |
<br> | |
<div id="button1" class="button">Button</div> | |
<div id="button2" class="button">Button2</div> | |
<div id="button3" class="buttontoo">Button3</div> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<script> | |
function calculate(){ | |
var myAge = 41; | |
var myAgeMax = 129; | |
var myCoffeesPerDay = 2; | |
var lifetimeCoffeeSupply = (((myAgeMax-myAge)*365)*myCoffeesPerDay); | |
var newDiv = $('<div></div>'); | |
newDiv.attr('id', 'testID'); | |
$('body').append(newDiv); | |
var div = $('#testID'); | |
div.html(); | |
div.html("You need "+lifetimeCoffeeSupply+" cups of coffee to last until your old age of "+myAgeMax +"."); | |
if (lifetimeCoffeeSupply > 40,000){ | |
div.append(" Wow! That's a lot!"); | |
} else { | |
div.append(" You seem pretty reasonable!"); | |
} | |
} | |
function sayHello(){ | |
alert ("hello"); | |
} | |
$(document).ready(sayHello); | |
function alertSomething(){ | |
alert ("hello"); | |
} | |
$("#button1").click(alertSomething); | |
$("#button1").click(function (){ | |
alert ("hello"); | |
}); | |
$(".button").click (function (){ | |
var contentsOfButton; | |
contentsofButton = $(this).html(); | |
alert (contentsofButton); | |
}); | |
$("#button").bind({ | |
click: function(){ | |
$(this).css("background-color", "green") | |
}, | |
mouseenter: function(){ | |
$(this).css("background-color", "purple") | |
} | |
}); | |
function colorChange(){ | |
$("#button3").bind({ | |
click: function(){ | |
$(this).css("color", "orange") | |
}, | |
mouseenter: function(){ | |
$(this).css("background-color", "blue") | |
} | |
}); | |
} | |
$(document).ready(colorChange); | |
<form> | |
<input | |
</form> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment