How to HIDE and SHOW HTML using JavaScript 🖼

preview_player
Показать описание
#JavaScript #tutorial #course

In this video, I'll be demonstrating how you can toggle between the display and/or visibility of an HTML image by adding an event listener to a button.
Рекомендации по теме
Комментарии
Автор

const myButton =
const myImg =

myButton.addEventListener("click", event => {

// DISPLAY
if(myImg.style.display === "none"){
myImg.style.display = "block";
myButton.textContent = "Hide";
}
else{
myImg.style.display = "none";
myButton.textContent = "Show";
}

// VISIBILITY
if(myImg.style.visibility === "hidden"){
myImg.style.visibility = "visible";
myButton.textContent = "Hide";
}
else{
myImg.style.visibility = "hidden";
myButton.textContent = "Show";
}
});

<!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="styles.css">
</head>
<body>

<img id="myImg" src="car.jpg" width="400px"><br>

<button

<script src="index.js"></script>
</body>
</html>

BroCodez
Автор

Bro is the best teacher ever.
















get it cuz his username bro

noobsense.
Автор

In case you didn’t already, can you make a tutorial on how to set up JS in vscode and what other extensions we need for it?

griswoldthegoblin
Автор

thanks teacher it will be good if you can make us one crash course of react please

learn-with-khaalid
Автор

how do you overlay the elements i cant figure it out

Mlurey_Real
Автор

bros doing gods work and gets 160 views

notthescorpion
Автор

Is possible to do that in java using spring boot ?

angefallen
Автор

Hey bro, just wanted to let you know that for some reason, your videos don’t appear in my sub box. I unsubscribed and re-subscribed and nothing changes. Not sure if it is just me experiencing this problem but I thought I’d let you know

dseanhd