为什么同一个按钮上无法设置两种animate属性呢,该怎样修改这段代码使同一个按钮点击一次时伸展,点击第二次时收缩呢?
<html><head><script type="text/javascript" src="/jquery/jquery.js"></script><script type="text/javascript">$(document).ready(function() { var l = $("#box").width(); if(l = "100px"){
$(".btn1").bind("click",function(){
$("#box").animate({width:"300px"});
});
}else{
$(".btn1").bind("click",function(){
$("#box").animate({width:"100px"});
});
};
});</script></head><body><div id="box" style="background:#98bf21;height:100px;width:100px;margin:6px;"></div><button class="btn1">Animate</button></body></html>
沧海一幻觉
慕尼黑5688855
随时随地看视频慕课网APP
相关分类