我有以下脚本,它可以使用slideUp和slideDown效果工作,但在设置DIV高度动画时不能正常工作:
$(function () {
var myTimer,
myDelay = 500;
$('.slide, .the_menu').hover(function () {
//when either a `img.menu_class` or a `.the_menu` element is hovered over, clear the timeout to hide the menu and slide the
我想让div的高度动画化。这通常是在CSS中通过设置max-height属性的动画来完成的。
然而,我需要在JS中做到这一点。div填充了频繁更改的动态内容,因此无法提前获知实际高度。
这是一个jsfiddle:
var box = document.getElementById("box");
var button = document.getElementById("button");
var expanded = true;
button.addEventListener('click', function() {
if (e