MyAnimate.timer = null;//默认增量MyAnimate.inc = 2;MyAnimate.speed = 10;//展开MyAnimate.unfold = function (id, max, inc,speed) { inc = inc || this.inc; speed = speed || this.speed var h = $('#' + id).height() if ( h < max ) { $('#' + id).height(h + inc) clearTimeout(MyAnimate.timer); timer = setTimeout('MyAnimate.unfold("' + id + '",' + max + ',' + inc + ','+speed+')', 10) }};//收缩折叠MyAnimate.fold = function (id, min, inc,speed) { inc = inc || this.inc; speed = speed || this.speed var h = $('#' + id).height() if ( h > min ) { $('#' + id).height(h - inc) clearTimeout(MyAnimate.timer); timer = setTimeout('MyAnimate.fold("' + id + '",' + min + ',' + inc +','+speed+ ')', 10) }};(function () { //点击展开、收缩,展开的id $(document).on('click', '[detail-collapse]', function () { var state = $(this).attr('detail-collapse'); if ( state == '0' ) {//收缩,执行展开 MyAnimate.unfold('prizeStateId', 84) $(this).attr('detail-collapse', 1) $(this).text('收起明细') } else {//展开,执行收缩 MyAnimate.fold('prizeStateId', 0) $(this).attr('detail-collapse', 0) $(this).text('明细') } })})()