Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
添加高度时如何编写jQuery动画_Jquery_Jquery Animate_Height - Fatal编程技术网

添加高度时如何编写jQuery动画

添加高度时如何编写jQuery动画,jquery,jquery-animate,height,Jquery,Jquery Animate,Height,这是我的代码,它的功能是获取bxspace高度,并在单击时添加15px。但我想在添加15px时应用animate()使其平滑移动。已在qjQuery下尝试,但不起作用 CSS .bxspace{height: 258px;} jQuery $('.bxspace').height( $('.bxspace').height() + 15 ); 我是jQuery的新手,不知道如何将这两种代码结合起来。希望你们中的一些人能给我一些建议。谢谢 对于接受数值的属性,可以在animate

这是我的代码,它的功能是获取
bxspace
高度,并在单击时添加
15px
。但我想在添加
15px
时应用animate()使其平滑移动。已在qjQuery下尝试,但不起作用

CSS   
.bxspace{height: 258px;}    

jQuery
$('.bxspace').height( $('.bxspace').height() + 15 );

我是jQuery的新手,不知道如何将这两种代码结合起来。希望你们中的一些人能给我一些建议。谢谢

对于接受数值的属性,可以在
animate()
中使用增量语法

尝试:


我明白了,我没想过这个方法。这很有效。谢谢。
var height = $('.bxspace').height( $('.bxspace').height() + 15 ); 
$('.bxspace').animate({height: height+'px'});
$('.bxspace').animate({height: "+=15"});