我有一个简单的代码来单击按钮并使用 jquery animate color 切换 div 大小和颜色,但问题是切换事件发生而不单击并且按钮消失
html:
<input type="button" id="togglemove" value="toggle div1 move" />
<input type="button" id="toggle" value="toggle" />
<div class="div1"></div>
jQuery:
$(document).ready(function(e) {
$("#toggle").toggle(click1,click2);
$("#togglemove").toggle(move1,move2);
});
function move1(){
$(".div1").animate({"left":"200px"},1000);
}
function move2(){
$(".div1").animate({"left":"100px"},1000);
}
function click1(){
$("div.div1").animate({"width":"400px","border-radius":"10px",'background-color': '#400101','left':'200px'},1000);
}
function click2(){
$("div.div1").animate({"width":"200px","border-radius":"0",'background-color': '#000000','left':'100px'},1000);
}
住在 jsfiddle 上:http: //jsfiddle.net/kaNP4/