HTML, JavaScript, jQuery, CSS
Key Ideas
Make a page, make it come to life, make it beautiful
Let’s build a $2,000 calculator!
But first, recall some key ideas….
Key HTML Ideas
A web page is a collection of HTML elements:
<h1>Important News</h1>
<p>This just in. Spam spam and beans contains spam!</p>
<button>like</button>
<button>don’t like</button>
<h1>Talk back</h1>
Would you like to leave us a comment?
<input type=text></input>
See our <a href=”www.photos.com”>photos page</a>
Key HTML ideas (2)
Key HTML ideas (3)
Key JavaScript Ideas
Key JavaScript Ideas (functions)
function getRandomFlavor() {
var flavors = [“chocolate”, “vanilla”, “strawberry”];
var flavorNumber = Math.floor(Math.random(flavors.length));
return flavors[flavorNumber];
}
Functions with parameters
function hasChocolate(flavorList) {
for (var i = 0; i < flavorList.length; i++) {
if (flavorList[i] == “Chocolate”) {
return true;
} else {
return false;
}
}
}
Key jQuery ideas
Example jQuery Selector
HTML
<p><span id=”day”></span> the weather will be
<span id=”forecast”></span>.</p>
<button id=”next”>Next</button>
JavaScript + jQuery
var days=[“Monday”, “Tuesday”, “Wednesday”];
var forecast=[“sunny”, “rainy”, “cloudy”];
var dayNumber = 0;
function showForecast(i) {
$(“#day”).text(days[i]);
$(“#forecast”).text(forecast[i]);
}
$(“#next”).click(function(){
dayNumber = (dayNumber+1) % 3;
showForecast(dayNumber);
});
CSS Key Ideas
Now Let’s Try This