Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views3 pages

JavaScript Is The World

JavaScript is the world's most popular programming language that can be inserted into HTML pages and executed by web browsers. It is used to write directly into HTML output, react to events like button clicks by displaying alerts, and manipulate the content of HTML elements by changing their inner HTML.

Uploaded by

Reena Madel
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
0% found this document useful (0 votes)
10 views3 pages

JavaScript Is The World

JavaScript is the world's most popular programming language that can be inserted into HTML pages and executed by web browsers. It is used to write directly into HTML output, react to events like button clicks by displaying alerts, and manipulate the content of HTML elements by changing their inner HTML.

Uploaded by

Reena Madel
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1/ 3

JavaScript is the world's most popular programming language.

It is the language for HTML and the web, for servers, PCs, laptops, tablets, smart phones, and more.

JavaScript is a Scripting Language


A scripting language is a lightweight programming language. JavaScript is programming code that can be inserted into HTML pages. JavaScript inserted into HTML pages, can be executed by all modern web browsers. JavaScript is easy to learn.

JavaScript: Writing Into HTML Output


<html> <body> <p> JavaScript can write directly into the HTML output stream: </p>

<script> document.write("<h1>This is a heading</h1>"); document.write("<p>This is a paragraph.</p>"); </script>

<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.

JavaScript: Reacting to Events


<html> <body> <h1>My First JavaScript</h1> <p> JavaScript can react to events. Like the click of a button: </p> <button type="button" onclick="alert('Welcome!')">Click Me!</button> </body> </html> Output:

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.

JavaScript: Changing HTML Content


Using JavaScript to manipulate the content of HTML elements is a very powerful functionality

<html> <body> <h1>My First JavaScript</h1>

<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

<button type="button" onclick="myFunction()">Click Me!</button>

</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.

You might also like