How to get to default appearance

假装没事ソ 提交于 2019-12-12 01:57:42

问题


This is a follow up to a problem posted earlier. Click here to open it

I now have the following code, but I can't get the second button that appears to adopt the default border and padding. Please help. Thanks.

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script> 
$(document).ready(function(){
  $("button").click(function(){
    $("#b1").animate({width:'0px', padding:'0', border:'0'}, { duration: 1000, queue: false });
    $("#b2").animate({width:'200px', padding:"", border:""}, { duration: 1000, queue: false });
  });
});
</script> 
<style>
button {
min-width:0px;
height: 22px;
width: 200px;
}

#b2 {
width: 0px;
padding: 0;
border: 0;
}


</style>
</head>

<body>
<button id="b1">Start Animation</button><button id="b2">Animation Done</button>

</body>
</html>

回答1:


maybe you can solve like below

css code:

button {
min-width:0px;
height: 22px;
width: 200px;
}

#b2 {
width: 0px; display:none;
}

jquery code:

 $("button").click(function(){
     $("#b1").animate({width:'0px',padding:'0px'}, 1000,function(){$('#b1').hide();});
     $("#b2").css('display','inline-block').animate({width:'200px'}, { duration: 1000, queue: false });
  });

you can see the result here ---> http://jsfiddle.net/Junkie/4c9g3/



来源:https://stackoverflow.com/questions/24841556/how-to-get-to-default-appearance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!