我使用jquery似乎有困难
.animate()
若要在按钮上从右到左对绝对定位的DIV设置动画,请单击,然后在另一个按钮上从左到右单击。我想知道你是否愿意帮助我理解我做错了什么?谢谢。下面是我的相关css、html和jquery代码。我可以点击
#moveLeft
按钮,它确实会在左侧设置动画,但当我单击
#moveRight
巴顿,什么都没发生。我哪里出错了?
谢谢!!
CSS
#scorecardTwo {
position:absolute;
padding:5px;
width: 300px;
background-color:#E1E1E1;
right:0px;
top:0px;
display:none;
}
HTML
<div id = "scorecardTwo">
<span id = "dealHolder"><a href="link/to/stuff">text</a></span>
<br />
<span id = "scoreHolder">text</span>
<br />
<button type="button" id="moveLeft">Left</button> <button type="button" id="moveRight">Right</button>
</div>
JQuery
$("#scorecardTwo").fadeIn("slow");
$("#moveLeft").bind("click", function() {
var config = {
"left" : function() {
return $(this).offset().left;
},
"right" : function() {
return $("body").innerWidth() - $K("#scorecardTwo").width();
}
};
$("#scorecardTwo").css(config).animate({"left": "0px"}, "slow");
$(this).attr("disabled", "disabled");
$("#moveRight").attr("disabled", "");
});
$("#moveRight").bind("click", function() {
var config = {
"left" : function() {
return $(this).offset().left;
},
"right" : function() {
return $("body").innerWidth() - $K("#scorecardTwo").width();
}
};
$("#scorecardTwo").css(config).animate({"right" : "0px"}, "slow");
$(this).attr("disabled", "disabled");
$("#moveLeft").attr("disabled", "");
});