更多操作
无编辑摘要 |
无编辑摘要 |
||
第2行: | 第2行: | ||
$('.collpased-container').each(function (i,v) { | $('.collpased-container').each(function (i,v) { | ||
$(this).attr('id','collapsed-'+i) | $(this).attr('id','collapsed-'+i) | ||
$(this).attr('defHeight',$('.data-folded').height()) | |||
$(this).bind('click',function(){ | $(this).bind('click',function(){ | ||
toggleCollapse('#collapsed-'+i) | toggleCollapse('#collapsed-'+i) | ||
第7行: | 第8行: | ||
}) | }) | ||
} | } | ||
function toggleCollapse(selector, openSpeed, closeSpeed){ | function toggleCollapse(selector, openSpeed, closeSpeed){ | ||
openSpeed = openSpeed !== undefined ? openSpeed : 'fast' | openSpeed = openSpeed !== undefined ? openSpeed : 'fast' | ||
closeSpeed = closeSpeed !== undefined ? closeSpeed : 'fast' | closeSpeed = closeSpeed !== undefined ? closeSpeed : 'fast' | ||
var defaultHeight = | selector = $(selector) | ||
var defaultHeight = selector.attr('defHeight') | |||
var paddingHeight = 10 | var paddingHeight = 10 | ||
var targetHeight = defaultHeight + paddingHeight + selector.children('.collpased-content').height() | var targetHeight = defaultHeight + paddingHeight + selector.children('.collpased-content').height() | ||
var currentHeight = selector.height() | var currentHeight = selector.height() |
2023年2月10日 (五) 18:29的版本
function bindCollpase() {
$('.collpased-container').each(function (i,v) {
$(this).attr('id','collapsed-'+i)
$(this).attr('defHeight',$('.data-folded').height())
$(this).bind('click',function(){
toggleCollapse('#collapsed-'+i)
})
})
}
function toggleCollapse(selector, openSpeed, closeSpeed){
openSpeed = openSpeed !== undefined ? openSpeed : 'fast'
closeSpeed = closeSpeed !== undefined ? closeSpeed : 'fast'
selector = $(selector)
var defaultHeight = selector.attr('defHeight')
var paddingHeight = 10
var targetHeight = defaultHeight + paddingHeight + selector.children('.collpased-content').height()
var currentHeight = selector.height()
if(defaultHeight === currentHeight){
selector.animate({
height: targetHeight
}, openSpeed,function () {
selector.removeClass('data-folded')
selector.css('height','auto')
});
}else {
selector.animate({
height: defaultHeight
}, closeSpeed);
selector.addClass('data-folded')
}
}
function tollgeAllCo(){
$('.collpased-a').each(function () {
$(this).click()
})
}
bindCollpase()