我试图使一个div在点击时改变位置,再次点击时恢复到原始位置。但我无论如何都无法弄清问题所在。
$("#bottom").click(function() {
var $about = $('#bottom'),
top = $about.css('top') === '50%' ? '90%' : '50%';
$about.stop().animate({top: top}, 500);
});
我的 CSS 如下:
#bottom {
top: 90%;
left: 0; right: 0;
height: 100%;
}
当我点击 #bottom 时,div 元素会定位在50%,但当我再次点击时,没有任何反应。