<head>
<style>
div {
position:absolute;
background-color:#abc;
left:100px;
width:90px;
height:90px;
margin:15px;
right:15px;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<button id="left">«</button>
<button id="right">»</button>
<div class="block"></div>
<script>
$("#right").click(function () {
$(".block").animate({
"left": "+=50px"
}, "slow");
});
$("#left").click(function () {
$(".block").animate({
"left": "-=50px"
}, "slow");
});
</script>
</body>
The question I have is the significance of “left” in $(“.block”).animate({“left”: “-=50px”}, “slow”); I changed to “right” on both now the block isn’t moving or animating now. It only seesm to work when “left”.
I believe when there is a conflict between
leftandright, left is taking precedence. You really shouldn’t be defining both, just one or the other.Remove
leftfrom thecssand then changing torightshould work.