Difference between revisions of "JavaScript"
Adelo Vieira (talk | contribs) |
Adelo Vieira (talk | contribs) (→Methods) |
||
Line 65: | Line 65: | ||
====Change HTML Attribute Values==== | ====Change HTML Attribute Values==== | ||
This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript": | This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript": | ||
− | + | ||
<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button> | <button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button> | ||
Line 71: | Line 71: | ||
<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button> | <button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button> | ||
− | + | ||
Revision as of 13:47, 14 October 2019
https://www.w3schools.com/js/default.asp
JavaScript and Java are completely different languages, both in concept and design.
JavaScript is one of the 3 languages all web developers must learn:
- HTML to define the content of web pages
- CSS to specify the layout of web pages
- JavaScript to program the behavior of web pages
Web pages are not the only place where JavaScript is used. Many desktop and server programs use JavaScript. Node.js is the best known. Some databases, like MongoDB and CouchDB, also use JavaScript as their programming language.
Contents
What JavaScript can do
What JavaScript can do / What is used for / some of the most important methods:
- JavaScript Can Change HTML Content
- JavaScript Can Change HTML Attribute Values
- JavaScript Can Change HTML Styles (CSS)
- JavaScript Can Hide HTML Elements
- JavaScript Can Show HTML Elements
Installation
IDE for JavaScript
Control flow statements
If statements
For Loops
While Loops
Methods
Some of the most important methods
https://www.w3schools.com/js/js_intro.asp
Change HTML Content
This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript":
document.getElementById("demo").innerHTML = "Hello JavaScript";
Change HTML Attribute Values
This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript":
<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>
<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>
Change HTML Styles - CSS
This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript":
Hide HTML Elements
This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript":
Show HTML Elements
This example uses the method to "find" an HTML element (with id="demo") and changes the element content (innerHTML) to "Hello JavaScript":