0
我想運行div高度變化的函數,如果div高度增加,我想添加一個類到body,如果高度降低到0
,則刪除類。使用jQuery執行高度改變功能
喜歡的東西:
$('.mydiv').change(function(){
// add class to boy if height increase
})
我想運行div高度變化的函數,如果div高度增加,我想添加一個類到body,如果高度降低到0
,則刪除類。使用jQuery執行高度改變功能
喜歡的東西:
$('.mydiv').change(function(){
// add class to boy if height increase
})
$('.mydiv').resize(function() {
if($(this).height() > 400){
$('body').removeClass('normal height bigheight').addClass('bigheight');
} else if ($(this).height() > 200){
$('body').removeClass('normal height bigheight').addClass('height');
} else if ($(this).height() > 0){
$('body').removeClass('normal height bigheight').addClass('normal');
} else {
$('body').removeClass('normal height bigheight');
}
});
見http://stackoverflow.com/questions/6726406/how-to-detect-and-change-div-height-in-jquery?rq=1 –
[使用jQuery檢測div的高度發生變化]的可能重複(http://stackoverflow.com/questions/172821/detecting-when-a-divs-height-changes-using-jquery) – Joe