JavaScript shows and hides pictures, for your reference, the specific content is as follows Click the button to show and hide the image (displayed by default). Attach the code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Show and hide images</title> </head> <body> <button id="btn">Hide</button> <br> <img src="img/image01.jfif" id="newGirlFriend"> <script type="text/javascript"> // 1. Get the event source var obtn = document.getElementById("btn"); var newImg = document.getElementsByTagName("img")[0]; // var isShow = true; // Method 2 // 2. Binding event obtn.onclick = function (){ // if (isShow) { // Method 2 if (obtn.innerHTML === 'Hide') { // 3. Event driver newImg.style.display = 'none'; obtn.innerHTML = "display"; // // isShow = false; // Method 2 }else { newImg.style.display = 'block'; obtn.innerHTML = "Hide"; // isShow = true; // Method 2 } } </script> </body> </html> There are two implementation methods, the implementation is as follows: This is the default display interface. After clicking hide, it will look like this: The simple function of showing and hiding pictures is now realized! The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed steps to install MySql 5.7.21 in Linux
>>: How to install iso file in Linux system
1. Download the tomcat image docker pull tomcat:8...
Table of contents 1. Date 2. RegExp 3. Original p...
There are two types of MySQL installation files, ...
This article example shares the specific code of ...
Today I helped a classmate solve a problem - Tomc...
All consecutive spaces or blank lines (newlines) ...
<br />In the field of network design, resear...
This is a collection of commonly used but easily ...
This article example shares the specific code of ...
Problem description: structure: test has two fiel...
On Unix-like systems, you may know when a command...
Isolation Level: Isolation is more complicated th...
1. Demand The local test domain name is the same ...
The latest download and installation tutorial of ...
public function json_product_list($where, $order)...