问题
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