Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use jQuery to achieve accordion effect

Shulou Source: shulou.com Published: 2022-06-01 02:40:15 10月02日 Update

This article mainly explains "how to use jQuery to achieve accordion effect". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use jQuery to achieve accordion effect".

Js Code:

$(function () {/ / get all li traversal $(".li _ list") .each (function () {/ / when the mouse enters the current li $(this) .mouseenter (function () {/ / sets the current element width $(this). Stop () .animate ({"width": "600px"}, 500, "linear")) / / set siblings () .siblings () .stop () .animate ({"width": "100px"}, 500, "linear");})

Css Code:

.li _ list {width: 100px; height: 300px; list-style: none; float: left; overflow: hidden;} .li _ list img {width: 100%; height: 100%;} .divbg {width: 600px; height: 300px; background: rgba (230,0,0,0.5); text-align: center; line-height: 300px; float: left } .divbg span {display: block; width: 100px; height: 300px; float: left;} .div1 {width: 500px; height: 300px; float: left;} .mo {width: 600px;}

Html Code:

Cute pet

Cute pet

Cute pet

Cute pet

Thank you for your reading, the above is the content of "how to use jQuery to achieve accordion effect". After the study of this article, I believe you have a deeper understanding of how to use jQuery to achieve accordion effect, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Accordion effects hand style code learning elements content width compatriots that is ideas situations articles more knowledge knowledge points articles follow questions mouse Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi Redmi vpn Shulou Tech Info