【发布时间】:2013-04-21 20:57:10
【问题描述】:
我想在点击事件上使用 jquery 调整 div 的宽度,但我似乎无法弄清楚确切的语法是什么。
下面是我目前尝试过的一个例子。
$(function() {
$("#square").on("click", function(){
if($(this).css("width", "50")){
$(this).animate({width:"500"}, 1000);
} else {
$(this).animate({width:"50"}, 1000);
}
});
});
提前致谢。
【问题讨论】:
-
你忘了在你的 jsfiddle 中包含 jquery 库,jsfiddle.net/Xotic750/4GGP8/2
标签: javascript jquery