JQuery + CSS semi-open folding effect principle and code (self-writing) _ jquery

Source: Internet
Author: User
JQuery makes a DIV element that can be semi-folded. Since accordion in jQueryUI does not provide relevant methods, I wrote one myself, the code quality is very low. I hope you can give me some advice on a project and want to use jQuery to create a DIV element that can be semi-folded. In jQueryUI, accordion did not provide relevant methods, so I wrote it myself. In the past, when using jQueryUI, we found that all the accordion that can be used were folded up, and there was no way to set the minimum collapse height.
The code quality is very low. I hope laruence can give some advice.

Is the effect display, which can be expanded and reduced by jQuery functions.

The Code is as follows:


// Author: hlhr
// Require: Jquery1.4 and above
Function animate_toggle_height (maxh, minh, maxo, mino, element, speed) {// This is vertical. parameter description: maximum height, minimum height, maximum transparency, minimum transparency, element, animation speed
If (element.css ("height") = minh. toString (). concat ("px") {// expand if it is the minimum height
Element. animate ({
Height: maxh,
Opacity: maxo
}, {Queue: false}, speed );
Return "Fold"
}
If (element.css ("height") = maxh. toString (). concat ("px") {// fold if it is the maximum height
Certificate (this).html ("");
Element. animate ({
Height: minh,
Opacity: mino
}, {Queue: false}, speed );
Return "Read more ";
}
}
Function animate_toggle_width (maxw, minw, maxo, mino, element, speed ){
If (element.css ("width") = minw. toString (). concat ("px ")){
Element. animate ({
Width: maxw,
Opacity: maxo
}, {Queue: false}, speed );
Return "Fold"
}
If (element.css ("width") = maxw. toString (). concat ("px ")){
Element. animate ({
Width: minw,
Opacity: mino
}, {Queue: false}, speed );
Return "Read more ";
}
}


The Code is as follows:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.