Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize Advertising display and Hidden Animation by jQuery

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report