0% found this document useful (0 votes)
17 views

JavaScript 1

The document introduces JavaScript, describing what it is, what it can be used for, and where JavaScript code runs. It explains that JavaScript is a popular programming language used widely on the web and in applications. It provides examples of how JavaScript can manipulate HTML and change content and attributes.

Uploaded by

leonnika1908
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

JavaScript 1

The document introduces JavaScript, describing what it is, what it can be used for, and where JavaScript code runs. It explains that JavaScript is a popular programming language used widely on the web and in applications. It provides examples of how JavaScript can manipulate HTML and change content and attributes.

Uploaded by

leonnika1908
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

INTRODUCTION

TO
JAVASCRIPT
• What is javascript?
• What can you do with it?
• Where does javascript code run?
1.
• Javascript is one most of the most
popular and widely used
programming/designing language of
HTML and the Web.
• Javascript is easy to learn.
• Some big companies like Netflix, Paypal
build entire applications in Javascript.
2.
• You can build web or mobile apps
• Real time networking apps like chats and
video streaming service command line
tools or even games.
• Many desktop and server programs
• use JavaScript.
• Some databases, like MongoDB and
CouchDB use Javascript as their
programming language.
3.
• Browser – Javascript engine(Chrome
v8) console.log(’Hello world’);
• Node(Visual Studio Code)
Applications of Javascript Programming
• Client side validation
• Manipulating HTML Pages
• User Notifications (raise dynamic pop-ups)
• Back-end Data Loading
• Presentations
• Server Applications
JavaScript Can Change HTML
Content
• One of many JavaScript HTML methods is
getElementById()
• document.getElementById("demo").inerHTML
= "Hello JavaScript";
• Exercise 1: Write JavaScript code to display
your name, surname and class
• <!DOCTYPE html>
• <html>
• <body>
• <h2>What Can JavaScript Do?</h2>
• <p id="demo">JavaScript can change HTML content.</p>
• <button type="button" onclick='document.getElementById("demo")
• .innerHTML = "Hello JavaScript!"'>Click Me!
• </button>
• </body>
• </html>
JavaScript Can Change HTML Attribute Values
• In this example JavaScript changes the
value of the src (source) attribute of an
<img> tag
<button type=“button”
onclick="document.getElementById('myIma
ge').src=‘picbulbon.jpg’">
Turn on the light</button>
<img id="myImage" src="picbulbon.jpg"
style="width:100px">
<button type=“button”
onclick="document.getElementById('myIma
ge')".src=picbulboff.jpg'">Turn off the
light</button>
Exercise 2:
Create a voting system with given “YES” and “NO” photos.
When you click YES button it shows YES photo.

You might also like