HTML and CSS Reference
In-Depth Information
5. Use the following JavaScript function in a .js file and create an HTML document
to produce the output shown here:
function get_fortune() {
today = new Date();
sayings = new Array(
"Carpe Diem.",
"Silence is golden but duck tape is silver.",
"An apple a day keeps the doctor away.",
"To each his own.",
"If at first you don't succeed, try again.",
"Never settle for mediocrity, strive for success",
"Live and let live."
);
n=sayings.length;
number = Math.floor(Math.random()*n);
fortune = "Today is "+today+ ".<br /><br />Today's fortune:
<br /><br /><em>" +sayings[number] +"</em>";
document.getElementById('divsaying').innerHTML = fortune;
}
6. Create a document that contains a table with at least two rows and columns.
Put text in the table cells using the DOM.
7. Write a function that can be used to add and remove an event listener. The
function will be cross-browser compliant. It will take three arguments: a refer-
ence to the object, the event ( click , onclick ), and the function that will handle
the event. The W3C Boolean value will be set to false . You can rewrite Example
15.23 using your functions.
Search WWH ::




Custom Search