Case Structure in Javascript
When I was using this on my contextual page headings page it was not working on an iPad but was on a Windows computer.
I want to use this page to demonstate the w3-code container.
Examples from W3C page
Above is an empty paragraph. Well, actually it echos the date until the button is clicked
The tag openings < need to be changed to <
The JavaScript (need to add br tags)
function myFunction() {
var text;
switch (new Date().getDay()) {
case 6:
text = "Today is Saturday";
break;
case 0:
text = "Today is Sunday";
break;
default:
text = "Looking forward to the Weekend";
}
document.getElementById("demo").innerHTML = text;
}
The code is hi-lighted using www.w3schools.com/lib/w3codecolor.js
The use of the pre tag maintains the indenting and you don't need the line breaks - However, it doesn't wrap on small screens
The JavaScript using the pre tag (no br tags)
function myFunction() {
var text;
switch (new Date().getDay()) {
case 6:
text = "Today is Saturday";
break;
case 0:
text = "Today is Sunday";
break;
default:
text = "Looking forward to the Weekend";
}
document.getElementById("demo").innerHTML = text;
}