Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize Advertising display and Hidden Animation by jQuery

Shulou Source: shulou.com Published: 2022-05-31 13:50:01 09月24日 Update

This article introduces the relevant knowledge of "jQuery how to realize advertisement display and hidden animation". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

We often see ads appear after a few seconds, and the ads disappear after a few seconds. Here's how to use the JQuery framework to achieve this feature.

The code is as follows:

Automatic Display and Hide of Advertisements #content{width:100%;height:500px;background:#999} /* Requirements: 1. When the page loads, three seconds later. Automatic display of advertisements 2. After 5 seconds, the advertisement automatically disappears. Analysis: 1. Use a timer to complete it. setTimeout 2. Analysis found that JQuery display and hide animation effect is actually control display 3. Use the show/hide method to complete the display of ads */ //entry function, after the page load is complete, define the timer, call these two methods $(function () { //Define timer, execute adShow method once after 3 seconds setTimeout(adShow,3000); //Define timer, call adHide method, execute once after 8 seconds setTimeout(adHide,8000); }); //Display ads function adShow() { //Get ad div, call display method $("#ad").show("slow"); } //hide ads function adHide() { //Get ad div, call hidden method $("#ad").hide("slow"); }

body part Directory structure:

Run Results:

At the beginning of the entry, the advertisement was not displayed

Three seconds later, the ad appears.

The ad will disappear in five seconds.

"jQuery how to achieve advertising display and hidden animation" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Advertising methods timers animation content more knowledge pages analysis practicality learning and then two code entry functions functions dilemmas actually that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn NVidia MySQL Linux