1 / 8

JavaScript: How To?

JavaScript: How To?. B. Ramamurthy. Structure – Style -- Interaction. HTML provides structure CSS provides style Javascript (script) provides control for interaction and operations. Simple JS. <!DOCTYPE html> <html> <head> <title> My first JavaScript </title> </head>

Download Presentation

JavaScript: How To?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaScript: How To? B. Ramamurthy

  2. Structure – Style -- Interaction HTML provides structure CSS provides style Javascript (script) provides control for interaction and operations

  3. Simple JS <!DOCTYPE html> <html> <head> <title> My first JavaScript </title> </head> <body> <h1> <script> document.write(“Hello, World!”); </script> </h1> </body> </html>

  4. JS functions A function consists of function followed by the name of the function The statement that make up the function go next within curly brackets Example: function saySomething() { alert(“ We are getting ready for the exam 1”); }

  5. Moving JS to an external file Similar to how we separated style elements in css file, behavioral elements can be moved to an external js file.

  6. HTML with External File JS <!DOCTYPE html> <html> <head> <title> My second JavaScript </title> <script src=“script2.js”></script> </head> <body> <h1 id=“helloMessage”> </h1> </body> </html>

  7. JS file window.onload= writeMessage; function writeMessage(){ document.getElementById(helloMessage).innerHTML = “Hello, World!”; }

  8. Basic Elements of a web page webpage Web browser Firefox, Safari .css file .html file displays interprets image and audio files .js Prepare/edit files

More Related