IT Notes
IT Notes
Roll no :- 10877
Semester :- V-B
Question 3 Create an HTML page that shows information about you, your course, hobbies,
address, and your plans. Use CSS for styling of HTML page so that looks nice.
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<article class="card">
<div class="thumb1"></div>
<div class="infos">
<h2 class="title">prashant mishra <span class="flag"></span></h2>
<h3 class="date">Bsc hons computer science</h3>
<h3 class="seats">footbaal badminton coding</h3>
<p class="txt">
5|Page
</div>
</body>
</html>
Style.css
*{
box-sizing: border-box;
}
html, body {
font-size: 100%;
}
body {
padding: 0;
margin: 0;
background: #9945b5;
background: url("bk23.jpg");
}
.container{
display: flex;
flex-direction: row;
6|Page
flex-wrap: wrap;
justify-content: space-evenly;
align-items: center;
}
article.card {
width: 350px;
height: 350px;
margin: 50px;
border-radius: 3px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
overflow: hidden;
}
article.card .thumb1 {
width: auto;
height: 260px;
background: url("pb.jpg") no-repeat center;
background-size: cover;
border-radius: 3px;
}
article.card .thumb2 {
width: auto;
height: 260px;
background: url("sb.jpg") no-repeat center;
background-size: cover;
border-radius: 3px;
}
article.card .infos {
width: auto;
height: 350px;
position: relative;
padding: 14px 24px;
background: #000000;
transition: 0.4s 0.15s cubic-bezier(0.17, 0.67, 0.5, 1.03);
}
article.card .infos .title {
position: relative;
margin: 10px 0;
letter-spacing: 3px;
color: #ffffff;
font-family: "Grotesque Black", sans-serif;
font-size: 1rem;
text-transform: uppercase;
text-shadow: 0 0 0px #afbcca;
}
7|Page
cursor: pointer;
opacity: 0;
transition: 0.5s 0.25s cubic-bezier(0.17, 0.67, 0.5, 1.03);
}
article.card:hover .infos {
transform: translateY(-260px);
background: transparent;
color: #090808;
}
article.card:hover .thumb1{
background: transparent;
}
article.card:hover .thumb2{
background: transparent;
}
article.card:hover .infos .seats, article.card:hover .infos .txt, article.card:hover .infos
.details {
opacity: 1;
color: black;
}
article.card:hover .infos .date{
color: black;
}
article.card:hover .infos .title{
color: black;
}
Output ss
9|Page
question 4. Create an HTML page with the sole purpose to show multiplication tables of 2 to
10 (row-wise) created by JavaScript. Initially, the page is blank. With help of setInterval
function print a row every 5 seconds in different colors and increasing font size.
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multiplication Tables</title>
10 | P a g e
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<style>
.multiplication-table {
margin: 10px;
transition: font-size 0.5s, background-color 0.5s;
}
<div id="multiplicationTablesContainer"></div>
<script>
function generateRandomColor() {
const letters = '0123456789ABCDEF';
let color = '#';
for (let i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
function displayNextTable() {
11 | P a g e
</body>
</html>
Output ss
12 | P a g e
13 | P a g e
Question 5. Create an HTML page with a paragraph written on it and under which 9 buttons
are placed in a 3X3 grid. The first row is for buttons labeled with colors names Red, Green,
and Blue, the second row with numbers 10, 20, 30, and the third row with different font
names. Click event of each of the buttons should make the appropriate change in the style of
paragraph.
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Button Grid</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
}
#button-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin-top: 20px;
}
.button {
14 | P a g e
<script>
function changeColor(color) {
document.getElementById('paragraph').style.color = color;
}
function changeFontSize(fontSize) {
document.getElementById('paragraph').style.fontSize = fontSize + 'px';
}
function changeFont(font) {
document.getElementById('paragraph').style.fontFamily = font;
}
</script>
</body>
15 | P a g e
</html>
Output ss
16 | P a g e
Question 6. Create a form that takes data about a pet. The form must be well designed and
should accept the , and what it likes most. At the submission of this form create a Pet object
in JavaScript filled with these values and log that object and equivalent JSON on the console.
P6.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
17 | P a g e
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.form-group {
margin-bottom: 15px;
}
label {
font-weight: bold;
display: block;
}
input[type="text"],
input[type="number"] {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 3px;
cursor: pointer;
}
</style>
</head>
18 | P a g e
<body>
<div class="container">
<h2>Pet Data Form</h2>
<form id="petForm">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="age">Age:</label>
<input type="number" id="age" name="age" required>
</div>
<div class="form-group">
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" name="weight" required>
</div>
<div class="form-group">
<label for="type">Type:</label>
<input type="text" id="type" name="type" required>
</div>
<div class="form-group">
<label for="likes">What it likes most:</label>
<input type="text" id="likes" name="likes" required>
</div>
<script>
name: name,
age: parseInt(age),
weight: parseFloat(weight),
type: type,
likes: likes
};
}
console.log(pet);
console.log(JSON.stringify(pet))
}
</script>
20 | P a g e
</body>
</html>
Output ss
question 7. Store JSON data of few pets that you created in previous practical in a JSON file
(copy from console output of previous program to a .json file). Using AJAX, load data from
the file and display it in a presentable way using HTML and CSS.
Data.json
[
{
"name": "tp1",
"age": "10",
"weight": "20",
"type": "gs",
"likes": "sleeping"
},
{
"name": "tp1",
"age": "10",
"weight": "20",
"type": "gs",
"likes": "sleeping"
},
{
21 | P a g e
"name": "tp1",
"age": "10",
"weight": "20",
"type": "gs",
"likes": "sleeping"
},
{
"name": "tp1",
"age": "10",
"weight": "20",
"type": "gs",
"likes": "sleeping"
},
{
"name": "tp1",
"age": "10",
"weight": "20",
"type": "gs",
"likes": "sleeping"
},
{
"name": "tp1",
"age": "10",
"weight": "20",
"type": "gs",
"likes": "sleeping"
}
]
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pets Information</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f2f2f2;
margin: 0;
padding: 20px;
text-align: center;
}
22 | P a g e
h1 {
color: #333;
}
.pet-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 20px;
margin-top: 20px;
}
.pet-card {
border: 1px solid #ddd;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
width: 250px;
transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
}
.pet-card:hover {
transform: scale(1.05);
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.pet-card h2 {
color: #fff; /* White text color for contrast */
margin-bottom: 0;
}
.pet-card p {
color: #eee; /* Light gray text color for contrast */
margin: 5px 0;
}
</style>
</head>
<body>
<h1>Pets Information</h1>
<script>
// Function to generate a random vibrant color
function getRandomColor() {
23 | P a g e
pets.forEach(function(pet) {
var petCard = document.createElement("div");
petCard.className = "pet-card";
petCard.innerHTML = `
<h2>${pet.name}</h2>
<p>Age: ${pet.age}</p>
<p>Weight: ${pet.weight}</p>
<p>Type: ${pet.type}</p>
<p>Likes: ${pet.likes}</p>
`;
petCard.style.backgroundColor = getRandomColor();
petContainer.appendChild(petCard);
});
}
Output ss
Question 8. Create a plain HTML page for B.Sc. Hons CS course, mentioning details like fee,
eligibility criteria, papers with names and credits, and future possibilities after the course. A
button for styling should be there at bottom of the page. On clicking on this button
JavaScript should redesign the complete page using jQuery in a nice presentable way.
Index.html
<!DOCTYPE html>
<html>
<head>
<title>B.Sc. Hons Computer Science</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div class="container">
<h1>Bachelor of Science (B.Sc. Hons) in Computer Science</h1>
<h2>Course Details</h2>
<p><strong>Fee:</strong> ₹ 27000 per year</p>
<p><strong>Eligibility Criteria:</strong> Minimum 12th-grade education with a focus
on mathematics and computer
science subjects.</p>
<p><strong>Papers with Names and Credits:</strong></p>
25 | P a g e
<ul>
<li>Introduction to Computer Science (4 credits)</li>
<li>Data Structures and Algorithms (4 credits)</li>
<li>Database Management (4 credits)</li>
<li>Web Development (4 credits)</li>
<li>Artificial Intelligence (4 credits)</li>
</ul>
<h2>Future Possibilities</h2>
<p>After completing this course, you can pursue various career options such as
software development, data
analysis, network administration, and more.</p>
<p>Click the button below to style the page:</p>
<button id="styleButton">Style Page</button>
</div>
<script>
// jQuery function to style the page on button click
$(document).ready(function () {
$("#styleButton").click(function () {
$("body").css({
"font-family": "Arial , sans-serif",
"margin": "0",
"padding": "0",
"background-color": "#f2f2f2",
});
$(".container").css({
"max-width": "900px",
"margin": "0 auto",
"padding": "20px",
"background-color": "#fff",
"border-radius": "5px",
"box-shadow": "0 0 10px rgba(0, 0, 0, 0.1)",
});
$("button").css({
"background-color": "#007bff",
"color": "#fff",
"border": "none",
"padding": "10px 20px",
"border-radius": "3px",
"cursor": "pointer",
});
});
});
</script>
</body>
26 | P a g e
</html>
Output ss
Question 9. Create an HTML page for an image gallery which shows the use of BOOTSTRAP
to rearrange and resize its contents on resizing the browser.
Index.html
<!DOCTYPE html>
<html lang="en">
27 | P a g e
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
.container1 {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 0 10px rgba(112, 37, 37, 0.1);
}
.image-container {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
gap: 10px;
max-width: 100%;
margin: 0 auto;
padding: 20px;
border-radius: 5px;
background-color: rgb(0, 0, 0);
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
transition: background-color 0.5s;
}
.image-container img {
max-width: 100%;
height: auto;
transition: box-dow 0.5s;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-
T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
crossorigin="anonymous"
/>
</head>
<body>
<div class="container1 container">
<input type="number" placeholder="enter number of imaages" id="input" />
28 | P a g e
</div>
});
</script>
</body>
</html>
Output ss
29 | P a g e
30 | P a g e
Question 10 Create an HTTP server using Node.js which handles requests on port 10000 or a
free port beyond 10000. Modify the server in such a way that opening localhost:10000 will
display “hello world ,this is my node.js server “ on browser
Server.js
const http = require('http');
server.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}/`);
});
Output ss
31 | P a g e
Question 11 Create index.html file containing two forms for SignIn and SignUp. Submitting
SignIn form should search for credentials in mysql database using server created in previous
practical. On successful signin, a welcome page should be displayed. Submitting SignUp form
should insert new entry for credentials in mysql database using server created in previous
practical. On successful signup, user should be returned back to index.html.
Index.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>SignInUp</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<main class="container" id="container">
<div class="form-container sign-up-container">
<form action="http://localhost:3000/signup" method="POST">
<h1>Sign Up</h1>
<input type="text" name="name" placeholder="Name" />
<input type="email" name="email" placeholder="Email" />
32 | P a g e
<script src="./script.js"></script>
</body>
</html>
Script.js
const signUpButton = document.getElementById('signUp');
const signInButton = document.getElementById('signIn');
const container = document.getElementById('container');
signUpButton.addEventListener('click', () => {
container.classList.add("right-panel-active");
});
signInButton.addEventListener('click', () => {
33 | P a g e
container.classList.remove("right-panel-active");
});
Style.css
@import url('https://fonts.googleapis.com/css?family=Montserrat:400,800');
*{
box-sizing: border-box;
}
body {
background: #f6f5f7;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
font-family: 'Montserrat', sans-serif;
height: 100vh;
margin: 0;
padding: 0;
}
h1 {
font-weight: bold;
margin: 0;
}
h2 {
text-align: center;
}
p{
font-size: 14px;
font-weight: 100;
line-height: 20px;
letter-spacing: 0.5px;
margin: 20px 0 30px;
}
span {
font-size: 12px;
}
a{
color: #333;
34 | P a g e
font-size: 14px;
text-decoration: none;
margin: 15px 0;
}
button {
border-radius: 20px;
border: 1px solid #07070A;
background-color: #07070A;
color: #ffffff;
font-size: 12px;
font-weight: bold;
padding: 12px 45px;
letter-spacing: 1px;
text-transform: uppercase;
transition: transform 80ms ease-in;
}
button:active {
transform: scale(0.95);
}
button:focus {
outline: none;
}
button.ghost {
background-color: transparent;
border-color: #ffffff;
}
form {
background-color: #ffffff;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0 50px;
height: 100%;
text-align: center;
}
form h1 {
margin-bottom: 0.33em;
}
input {
35 | P a g e
background-color: #eee;
border: none;
padding: 12px 15px;
margin: 8px 0;
width: 100%;
}
.container {
background-color: #fff;
box-shadow: 0 14px 28px rgba(0,0,0,0.22), 0 10px 10px rgba(0,0,0,0.22);
position: relative;
overflow: hidden;
width: 768px;
max-width: 100%;
min-height: 480px;
border-radius: 100px;
}
.form-container {
position: absolute;
top: 0;
height: 100%;
transition: all 0.6s ease-in-out;
}
.sign-in-container {
left: 0;
width: 50%;
z-index: 2;
}
.container.right-panel-active .sign-in-container {
transform: translateX(100%);
}
.sign-up-container {
left: 0;
width: 50%;
opacity: 0;
z-index: 1;
}
.container.right-panel-active .sign-up-container {
transform: translateX(100%);
opacity: 1;
z-index: 5;
animation: show 0.6s;
36 | P a g e
@keyframes show {
0%, 49.99% {
opacity: 0;
z-index: 1;
}
50%, 100% {
opacity: 1;
z-index: 5;
}
}
.overlay-container {
position: absolute;
top: 0;
left: 50%;
width: 50%;
height: 100%;
overflow: hidden;
transition: transform 0.6s ease-in-out;
z-index: 100;
}
.container.right-panel-active .overlay-container{
transform: translateX(-100%);
}
.overlay {
background: #24272B;
background: linear-gradient(to right, #07070A, #24272B);
background-repeat: no-repeat;
background-size: cover;
background-position: 0 0;
color: #ffffff;
position: relative;
left: -100%;
height: 100%;
width: 200%;
transform: translateX(0);
transition: transform 0.6s ease-in-out;
}
.container.right-panel-active .overlay {
transform: translateX(50%);
}
37 | P a g e
.overlay-panel {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0 40px;
text-align: center;
top: 0;
height: 100%;
width: 50%;
transform: translateX(0);
transition: transform 0.6s ease-in-out;
}
.overlay-left {
transform: translateX(-20%);
}
.container.right-panel-active .overlay-left {
transform: translateX(0);
}
.overlay-right {
right: 0;
transform: translateX(0);
}
.container.right-panel-active .overlay-right {
transform: translateX(20%);
}
.social-container {
margin: 20px 0;
}
.social-container a {
border: 1px solid #DDDDDD;
border-radius: 50%;
display: inline-flex;
justify-content: center;
align-items: center;
margin: 0 5px;
height: 40px;
width: 40px;
}
38 | P a g e
footer {
background-color: #222;
color: #fff;
font-size: 14px;
bottom: 0;
position: fixed;
left: 0;
right: 0;
text-align: center;
z-index: 999;
}
footer p {
margin: 10px 0;
}
footer i {
color: red;
}
footer a {
color: #3c97bf;
text-decoration: none;
}
Server.js
const http = require('http');
const url = require('url');
const fs = require('fs');
const path = require('path');
const querystring = require('querystring');
const mysql = require('mysql2');
const cors = require('cors');
req.on('end', () => {
const { name, email, password } = querystring.parse(data);
connection.query('INSERT INTO users (name, email, password) VALUES (?, ?, ?)', [name,
email, password], (error, results) => {
if (error) {
res.writeHead(500, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Internal Server Error' }));
} else {
res.writeHead(201, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'User created successfully' }));
}
});
}
});
} else if (pathname === '/signin' && req.method === 'POST') {
let data = '';
req.on('data', chunk => {
data += chunk;
});
req.on('end', () => {
const { email, password } = querystring.parse(data);
if (user) {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Sign in successful', user }));
} else {
res.writeHead(401, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Invalid email or password' }));
}
});
} else {
res.writeHead(404, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Not Found' }));
}
});
Output ss
41 | P a g e
<title>Document</title>
</head>
<body>
<input id="inp" type="number" placeholder="enter a number" />
<button id="btn" type="submit">submit</button>
<button id="sortout">show sorted array on console</button>
<script>
var arr = [];
var k = 0;
function bubbleSort(arr1) {
var i, j;
var len = arr1.length;
bubbleSort(arr);
});
</script>
</body>
</html>
Output ss
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital clock</title>
</head>
<script>
function clock(){
let time=new Date()
let hours=time.getHours()
let minuits=time.getMinutes()
let seconds=time.getSeconds()
var pid=hours+":"+minuits+":"+seconds;
44 | P a g e
document.getElementById("timing").innerHTML=pid;
}
setInterval(clock,1000);
</script>
<body>
<p id="timing">
</p>
</body>
</html>
Output ss
45 | P a g e
3 div slider on clicking one div para inside it becomes visible and all other div closes if a div
with para visible is clicked it hides the para
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Toggle Paragraphs</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
46 | P a g e
.div {
height: 40px;
font-size: 20px;
background-color: #3498db; /* Blue */
color: #fff; /* White */
transition: all 2s;
cursor: pointer;
box-shadow: 5px 5px 10px #2c3e50; /* Darker Blue */
margin: 15px;
text-shadow: 2px 2px 3px #000000; /* Slightly Darker Blue */
}
.div.active {
height: 160px;
font-size: 30px;
background-color: black; /* Red */
color: #e74c3c;
box-shadow: 5px 5px 10px #c0392b; /* Darker Red */
transition: all 2s;
text-shadow: 2px 2px 2px #922b21; /* Slightly Darker Red */
}
p {
box-shadow: -5px -5px 10px #717779; /* Gray */
background-color: #181616; /* Dark Gray */
height: 90px;
text-shadow: 2px 2px 2px #000; /* Black */
}
</style>
</head>
<body>
<div id="1" class="div">div1
<p class="para">para1</p>
</div>
<div id="2" class="div">div2
<p class="para">para2</p>
</div>
<div id="3" class="div">div3
<p class="para">para3</p>
</div>
<div id="4" class="div">div4
<p class="para">para4</p>
</div>
<script>
$(document).ready(function() {
$('p').hide();
47 | P a g e
$('.div').click(function() {
var isParagraphVisible = $(this).find('.para').is(':visible');
if (!isParagraphVisible) {
$(this).find('.para').show(2000);
$(this).addClass('active');
}
});
});
</script>
</body>
</html>
Output ss
48 | P a g e
49 | P a g e
50 | P a g e
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#1 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
}
.grid-item {
border: 1px solid black;
padding: 8px;
}
</style>
</head>
<body>
<div id="1"></div>
<div id="inputArea">
<input type="text" id="name" placeholder="Name">
<input type="text" id="email" placeholder="Email">
<input type="text" id="phone" placeholder="Phone Number">
<input type="text" id="gender" placeholder="Gender">
51 | P a g e
<button id="submitButton">Submit</button>
</div>
<script>
var ele = document.getElementById("1");
var inputArea = document.getElementById("inputArea");
function submitForm() {
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var phone = document.getElementById("phone").value;
var gender = document.getElementById("gender").value;
createGridItem("Name:", name);
createGridItem("Email:", email);
createGridItem("Phone Number:", phone);
createGridItem("Gender:", gender);
document.getElementById("name").value = "";
document.getElementById("email ").value = "";
document.getElementById("phone").value = "";
document.getElementById("gender").value = "";
}
Output
52 | P a g e
5 image slider
Index.html
<!DOCTYPE html>
<html>
<head>
<title>
IMAGE MOVE
</title>
<style type="text/css">
button{
53 | P a g e
background-color: black;
color: white;
padding: 8px;
}
</style>
</head>
<body>
<img src="https://picsum.photos/200" id="i1">
<div class="button">
<button id="start" onclick="begin()">START</button>
<button id="stop" onclick="stop()">STOP</button>
</div>
<script type="text/javascript">
var a=document.getElementById('start');
var b=document.getElementById('stop');
var image=document.getElementById('i1');
var margin=0;
var interval;
function begin()
{
clearInterval(interval);
interval=setInterval(function(){
if(margin >= window.innerWidth - image.width){
margin=0;
}
image.style.marginLeft = margin+ "px";
margin+=5;
},10);
}
function stop(){
clearInterval(interval);
}
</script>
</body>
</html>
Output ss
54 | P a g e
55 | P a g e
56 | P a g e
6 image zoom
Index.html
<html>
<head>
<title>Image Zoom</title>
<style type="text/css">
div{
border: 2px solid black;
padding: 10px;
}
p{
text-align:center;
}
img{
padding-left: 500px;
}
</style>
</head>
<body>
<div>
<p>Move over the image to zoom in and out of the Image to zoom out</p>
<img src="https://picsum.photos/200" id="img" >
</div>
<script type="text/javascript">
var image=document.getElementById('img');
image.onmouseover=function(){
image.style.height="400px";
image.style.width="350px";
}
57 | P a g e
image.onmouseout=function(){
image.style.height="200px";
image.style.width="150px";
}
</script>
</body>
</html>
Output ss
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.form-container {
border: 2px solid #3498db;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
padding: 20px;
width: 400px;
background-color: #fff;
}
label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
transition: background-color 0.3s, color 0.3s;
}
input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
input[type="number"]:hover,
59 | P a g e
textarea:hover,
select:hover {
background-color: #f5f5f5;
color: #333;
}
input[type="radio"],
input[type="checkbox"] {
margin-right: 5px;
}
.button-group {
margin-top: 20px;
}
.button-group button {
margin-right: 10px;
padding: 10px 20px;
background-color: #3498db;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
.button-group button:hover {
background-color: #258cd1;
}
</style>
</head>
<body>
<div class="form-container">
<form>
<label for="name">Question 1:</label>
<input type="text" id="name" name="name" placeholder="Answer 1">
<label>Question 3:</label>
<div class="radio-group">
<input type="radio" id="radio1" name="question3"
value="option1">
<label for="radio1">Option 1</label>
<input type="radio" id="radio2" name="question3"
value="option2">
60 | P a g e
<label>Question 4:</label>
<div class="checkbox-group">
<input type="checkbox" id="checkbox1" name="question4"
value="option1">
<label for="checkbox1">Option 1</label>
<input type="checkbox" id="checkbox2" name="question4"
value="option2">
<label for="checkbox2">Option 2</label>
</div>
<div class="button-group">
<button type="submit">Submit</button>
<button type="reset">Reset</button>
</div>
</form>
</div>
</body>
</html>
Output ss
61 | P a g e
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="div1">
<p>para 1</p>
<p>para 2</p>
<p>para 3</p>
<p>para 4</p>
<div>divc 1</div>
<div>divc 2</div>
<div>divc 3</div>
</div>
<p>op1</p>
<p>op2</p>
<script>
var ele = document.getElementById("div1");
// Check if the child node is a paragraph and not the first paragraph
itself
if (child.nodeName === 'P' && child !== firstPara) {
siblingCount++;
}
}
</script>
</body>
</html>
Output ss
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
console.log(1)
var pn = "+917979097007"
const re = /[+91][0-9]{10}/;
console.log(pn.match(re));
var ea="[email protected]"
const re1=/([a-z0-9])+@[a-z]+[.][a-z]+([.][a-z]+)*/i;
console.log(ea.match(re1));
</script>
</body>
</html>
Output ss
<html>
<head>
</head>
<body>
64 | P a g e
<form>
Enter the value : <input type="text" id="inp">
<input type="button" value="Push" id="push">
<input type="button" value="Pop" id="pop"><br><br>
<textarea value="" rows="20" cols="40" id="output"></textarea>
</form>
<script>
let arr = [];
document.getElementById("push").addEventListener("click",(e)=>{
getVal=document.getElementById("inp").value;
arr.push(getVal);
document.getElementById("output").value=arr;
document.getElementById("inp").value=null;
})
document.getElementById("pop").addEventListener("click",(e)=>{
getVal=document.getElementById("inp").value;
arr.pop();
document.getElementById("output").value=arr;
document.getElementById("inp").value=null;
})
</script>
</body>
</html>