Switch/Case
Menu The Switch Case
 

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 &lt;

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;
}
Top

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;
}

Links

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links toother websites.

The External link is disabled to on this page, please visit other pages

Unlike most genealogical research websites tempusfugit.me.uk does not attempt to get you to "sign-up" when you click on one of their links.

This Wikipedia link is disabled.

The link on Wikipedia was to:

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links to other websites.

The External link is disabled to on this page, please visit other pages

Top

External Links - references

Top

Site design by Tempusfugit Web Design -