Skip to content

Instantly share code, notes, and snippets.

@katherineschultz
Created October 21, 2014 00:58
Show Gist options
  • Save katherineschultz/bee3aa378c4d8b02c64f to your computer and use it in GitHub Desktop.
Save katherineschultz/bee3aa378c4d8b02c64f to your computer and use it in GitHub Desktop.
<!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" class="button">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);
$("#button1").click(function (){
alert ("hello");
});
$("#button1").click (function (){
var contentsOfButton;
contentsofButton = $("#button1").html();
alert (contentsofButton);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment