0
我有這個代碼,當任何複選框被選中時自動增加div高度,當未選中時降低高度,但是我想在屏幕上垂直居中時增加或減少div身高,我該怎麼辦?具有自動增量功能的中心div(高度)
感謝您的幫助!
http://jsfiddle.net/MetCastle/6adby/
$(function() {
$(':checkbox').click(function() {
$(".scroll").show();
var delta = $(this).is(':checked') ? -1 : 1;
if(delta < 0){
$("#scroll").append("<h2>" + $(this).next("label").html() + "</h2>");
$('.count').text(parseInt($('.count').text()) - 1);
}
else{
$("#scroll h2:contains('" + $(this).next("label").html() + "')").remove();
$('.count').text(parseInt($('.count').text()) + 1);
}
if ($(".count").text() == "0") {
var children = $('.options').children('input:not(:checked)');
for(var i= 0; i<children.length; i++) {
$(children[i]).prop('disabled', true);
}
} else {
var children = $('.options').children('input:not(:checked)');
for(var i= 0; i<children.length; i++) {
$(children[i]).prop('disabled', false);
}
}
if ($(".count").text() == "18") {
$(".scroll").hide();
}
});
});
這正是我需要的,非常感謝! –