Here is a case study on how to close ads using Javascript for your reference. The details are as follows: I am still learning the big front end. Please forgive me if there are any irregular or incorrect codes and ideas. Thank you for your advice. We can often see annoying small advertisements on web pages, and there is usually a specific position and icon next to the advertisement to close the advertisement. The following JS code is used to simply implement <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> *{ padding: 0; margin: 0; border: 0; } .gg{ width: 100%; height: 300px; background-image: url("../images/JD.png"); } .img{ width: 20px; height: 20px; float: right; } </style> </head> <body> <div class="gg"> <img class="img" src="../images/2.jpg" title="Close"> </div> <script> var gg = document.querySelector('.gg') var mg = document.querySelector('img') mg.onclick = function () { gg.style.display = 'none' } </script> </body> </html> Code Explanation The principle here is very simple. I put an annoying advertising picture at the bottom of the div, and then put a small icon representing close on it, and placed it in the upper right corner of the small advertisement. Then I get the event, and when it is onclick, the function is triggered. The content of the function is to hide this large div box directly and not display it, thus achieving the purpose of closing the advertisement. Demonstration effect Note the upper right corner After clicking the set location 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:
|
<<: How to change mysql password under Centos
>>: Problems and solutions for MYSQL5.7.17 connection failure under MAC
Open the decompressed directory of tomcat and you...
will-change tells the browser what changes will h...
There are two tables, and the records in table A ...
A situation that often occurs in a project is tha...
1. Introduction The requirement is to obtain the ...
Recently, I want to build a hadoop test cluster i...
This article shares the specific code of JavaScri...
Preface When I was working on a project recently,...
Mysql is a mainstream open source relational data...
How to solve the problem of forgetting the root p...
Table of contents Custom Vite plugins Using vite-...
Today, it suddenly occurred to me that it would be...
Hyperf official website Hyperf official documenta...
Linux change hostname command 1. If you only need...
Today, let's talk about a situation that is o...