JavaScript Is The World
JavaScript Is The World
It is the language for HTML and the web, for servers, PCs, laptops, tablets, smart phones, and more.
<p> You can only use <strong>document.write</strong> in the HTML output. If you use it after the document has loaded (e.g. in a function), the whole document will be overwritten. </p> </body> </html> You can only use document.write in the HTML output. If you use it after the document has loaded, the whole document will be overwritten.
My First JavaScript
JavaScript can react to events. Like the click of a button:
Click Me!
The alert() function is not much used in JavaScript, but it is often quite handy for trying out code. The onclick event is only one of the many HTML events you will learn about in this tutorial.
<p id="demo"> JavaScript can change the content of an HTML element. </p>
<script> function myFunction() { x=document.getElementById("demo"); // Find the element x.innerHTML="Hello JavaScript!"; } </script> // Change the content
</body> </html>
Output:::
My First JavaScript
Hello JavaScript!
Click Me!
You will often see document.getElementByID("some id"). This is defined in the HTML DOM. The DOM (Document Object Model) is the official W3C standard for accessing HTML elements.