Awd Paper 1 Answer
Awd Paper 1 Answer
1. Explain any five input tags used for forms with example
Definition of DOM
The Document Object Model (DOM) is a programming interface
for web documents. It represents the structure of a document
(e.g., HTML or XML) as a tree of objects, allowing developers to
interact with and manipulate the content, structure, and styling
of the document using scripting languages like JavaScript.
In the DOM:
Every HTML element becomes a node.
Developers can access, modify, add, or delete elements
dynamically.
2. getElementsByClassName()
Finds all elements that have a specific class name.
Returns a live HTMLCollection (arraylike object).
Syntax: document.getElementsByClassName("className")
Example:
javascript
const items =
document.getElementsByClassName("listitem");
console.log(items[0].textContent); // Access the first item
3. querySelector()
Finds the first element that matches a CSS selector.
Syntax: document.querySelector("selector")
Example:
javascript
const button = document.querySelector(".btnprimary");
console.log(button.innerText);
Client
A client is a program that runs on the local machine requesting service from
the server. A client program is a finite program means that the service
started by the user and terminates when the service is completed.
Server
A server is a program that runs on the remote machine providing services to
the clients. When the client requests for a service, then the server opens the
door for the incoming requests, but it never initiates the service.
A server program is an infinite program means that when it starts, it runs
infinitely unless the problem arises. The server waits for the incoming
requests from the clients. When the request arrives at the server, then it
responds to the request.
While Loop
The while loop creates a loop that is executed as long as a
specified condition evaluates to true. The loop will continue to
run until the condition evaluates to false. The condition is
specified before the loop, and usually, some variable is
incremented or altered in the while loop body to determine
when the loop should stop.
while (condition) {
// Code block to be executed
}
For example:
let i = 0;
while (i < 5) {
console.log(i);
i++;
}
do {
x = x + i;
console.log(x);
i++;
} while (i < 5);
For Loop
A for loop declares looping instructions, with three important
pieces of information separated by semicolons ;:
The initialization defines where to begin the loop by
declaring (or referencing) the iterator variable.
The stopping condition determines when to stop looping
(when the expression evaluates to false).
The iteration statement updates the iterator each time the
loop is completed.
for (let i = 0; i < 4; i += 1) {
console.log(i);
}
for...of Loop
for...in Loop
A for..in.. loop iterates over any object with string type keys
and allows for access to the values by indexreference. The
following accesses the keys:
const shoppingCart = { banana: 2, apple: 5,
cherry: 0 };
Reverse Loop
A for loop can iterate “in reverse” by initializing the loop
variable to the starting value, testing for when the variable hits
the ending value, and decrementing (subtracting from) the
loop variable at each iteration.
const items = ['apricot', 'banana', 'cherry'];
The <a> tag is used to create hyperlinks, allowing users to navigate to another page, section,
or external resource.
Attributes:
Example:
html
Output:
The <iframe> tag is used to embed another HTML document or resource (e.g., a webpage,
Attributes:
Example:
html
Output:
c. <strong> Tag
The <strong> tag is used to define text with strong importance. Browsers typically render it
as bold text.
html
Output:
"always" appears in bold: You should always wear a helmet while riding.
d. <sup> Tag
The <sup> tag is used to display text as superscript (smaller text raised above the baseline).
Example:
html
<p>E = mc<sup>2</sup></p>
Output:
Displays: E = mc²
e. <em> Tag
The <em> tag is used to emphasize text. Browsers typically render it as italic text.
Example:
html
Output: