Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Class notes 4310702

Rating
-
Sold
-
Pages
12
Uploaded on
01-03-2025
Written in
2024/2025

basics in javascript

Institution
Course

Content preview

JavaScript

JavaScript (JS) is a programming language that allows you to implement complex features on
web pages. It’s commonly used for:

●​ Adding interactivity (e.g., dynamic forms, buttons)
●​ Manipulating the Document Object Model (DOM)
●​ Communicating with APIs
●​ Validating user input
●​ Creating dynamic and responsive web apps

JavaScript is an essential part of the front-end web development stack along with HTML
(structure) and CSS (presentation).

How JavaScript Fits with HTML & CSS

●​ HTML is responsible for structuring the content on the web page (like headings,
paragraphs, images, and links).
●​ CSS is used to style this content, making the web page visually appealing by defining
colors, layouts, and fonts.
●​ JavaScript brings interactivity and dynamic behavior to the page. It can manipulate the
HTML structure (add/remove elements), change styles dynamically, and handle user
interactions (like clicks and key presses).

For example:

●​ HTML defines a button.
●​ CSS styles the button (size, color).
●​ JavaScript makes the button interactive, like showing an alert message when clicked.

Ways to Add JavaScript to a Webpage

There are three ways to add JavaScript to a webpage: Inline, Internal, and External.

1. Inline JavaScript

, Inline JavaScript is written directly inside an HTML tag using the onclick, onmouseover, or
other event attributes. It’s convenient for small scripts but not recommended for larger projects
because it can clutter the HTML.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML & JS</title>
</head>
<body>
<div>
<button onclick="alert('Hello, this is inline JavaScript!')">Click
Me</button>
</div>


</body>
</html>




Here, the JavaScript code alert('Hello, this is inline JavaScript!') is directly added inside the
HTML tag using the onclick event.

2. Internal JavaScript

Internal JavaScript is placed inside the <script> tag within the <head> or <body> section of the
HTML file. This method is better than inline JavaScript because it separates the behavior from
the HTML structure.

<!DOCTYPE html>

Written for

Institution
Course

Document information

Uploaded on
March 1, 2025
Number of pages
12
Written in
2024/2025
Type
Class notes
Professor(s)
Wachira
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
smocharingoz

Also available in package deal

Get to know the seller

Seller avatar
smocharingoz
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 year
Number of followers
0
Documents
17
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions