0% found this document useful (0 votes)
6 views6 pages

JS Lab Practise Questions

The document contains a series of JavaScript lab practice questions focusing on web technology. It includes code examples for changing textbox input to lowercase, displaying messages on mouse hover, checking for palindromes, and fetching specified substrings from a string. Each question is accompanied by HTML and JavaScript code snippets to demonstrate the required functionality.

Uploaded by

sammed biraje
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

JS Lab Practise Questions

The document contains a series of JavaScript lab practice questions focusing on web technology. It includes code examples for changing textbox input to lowercase, displaying messages on mouse hover, checking for palindromes, and fetching specified substrings from a string. Each question is accompanied by HTML and JavaScript code snippets to demonstrate the required functionality.

Uploaded by

sammed biraje
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name – Sammed Vijay Biraje Web-Technology

JS Lab Practise Questions Batch-B

Q.1 Write a program to change the value of textbox to lowercase as soon as user
inputs something into textbox.
Code-
<!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>Document</title>
<style>
body {
font-family: cursive;
}
</style>
<script src="Que_7.js"></script>
</head>

<body>
<h2>
Q.1 Write a program to change the value of textbox to lowercase as
soon as user inputs something into textbox.
</h2>
<hr> Enter something : <input type="text" id="in" oninput="[Link] =
[Link]()"></input>
</body>

</html>

Output-
Q.2 Write a program to print some message inside a div element as user moves
the mouse over div. Do it vice versa also.
Code-
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title></title>
<style>
.hide {
display: none;
}

.myDIV:hover+.hide {
display: block;
color: red;
}

body {
font-family: cursive;
font-size: 20px;
}
</style>
</head>

<body>
<h4>
Q.2 Write a program to print some message inside a div element as user
moves the mouse over div. Do it vice versa also.
</h4>
<div class="myDIV">Visit me.</div>
<div class="hide">Hello, How are you?</div>
</body>

</html>
Output-

Q3 Write a program to check whether a string input by user is a case of


palindrome or not.
Code-
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Document</title>
<style>
body {
font-family: cursive;
font-size: 20px;
}
</style>
</head>

<body>
<h4>
Q.3 Write a program to check whether a string input by user is a case
of palindrome or not.
</h4>
<hr> Enter String : <input type="text" id="str"></input>
<br>
<input type="button" value="check" onclick="check()"></input>
<br>
<p id="output"></p>

<script>
function check() {
var str = [Link]("str").value
var len = [Link];
alert(str)
alert(len)
for (let i = 0; i < len / 2; i++) {
if (str[i] !== str[len - 1 - i]) {
[Link]("output").innerHTML = "String is
not a palindrome";
} else {
[Link]("output").innerHTML = "String is
palindrome";
}
}
}
</script>
</body>

</html>

Output-
Q.4 Write a program to fetch the specified string of a string.
Code-
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>
document
</title>
<style>
body {
font-family: cursive;
font-size: 20px;
}
</style>
</head>

<body>
<h4>Write a program to fetch the specified string of a string.</h4>
Enter String : <input type="text" id="str"></input>
<br> Enter the character that you want to remove from the string
<input type="text" id="char"></input>
<br>
<input type="button" value="remove" onclick="subStrAfterChars()"></input>
<br>
<p id="output"></p>
<script>
function subStrAfterChars(str, char, pos) {
var str = [Link]("str").value;
var char = [Link]("char").value;

var output = [Link]([Link](char) + 1);


[Link]("output").innerHTML = output;
}
</script>
</body>

</html>
Output-

You might also like