Created
October 21, 2014 00:45
-
-
Save katherineschultz/4b08f45ae2cba65365b1 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> | |
<a href="#" id="button1">Button</a> | |
<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); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment