how to use java script

Answer Posted / fathimath thasneem

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Maximize Image Example</title>
<style>
.full-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
z-index: 9999;
}
#myImage {
width: 50%; /* Initially set to 50% of the container width */
cursor: pointer; /* Changes the cursor to a pointer to indicate it's clickable */
}
</style>
</head>
<body>

<img id="myImage" src="path_to_your_image.jpg" alt="Click to maximize">

<script>
const img = document.getElementById('myImage');

img.addEventListener('click', function() {
// Check if the image already has the full-screen class
if (img.classList.contains('full-screen')) {
img.classList.remove('full-screen'); // If yes, remove it (minimize)
} else {
img.classList.add('full-screen'); // Otherwise, add it (maximize)
}
});
</script>

</body>
</html>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are self invoking functions?

581


How long does it take to get good at javascript?

518


What is use of flutter?

572


What output will this program produce System.out.println(x+"+"+y+"="+(x+));

1644


What are .js files?

571






What are escape characters?

555


Consider the following code: 1 2 3 4 5 (function() { var a = b = 5; })(); console.log(b); what will be printed on the console?

550


Is function a data type in javascript?

562


What is a boolean search?

547


What is the best site to learn javascript?

547


How to create a confirmation box?

619


Define unescape() and escape() functions?

599


What are the variables in javascript?

655


What are JavaScript Cookies?

578


If 2 methods have same name and same number of parameters, which one will be executed first?

591