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: