I've been attempting to incorporate a sliding effect into my website, but I'm running into an issue where the sliding only occurs on the first click and I can't figure out why. Here is the code snippet I've been using: Html :
$("#go").click(function() {
$(".block").animate({
right: 85
}, {
duration: 800,
step: function(now, fx) {
$(".block:gt(0)").css("right", now);
}
});
});
div {
position: relative;
background-color: #abc;
width: 70px;
height: 70px;
float: left;
margin: 5px;
}
<p>
<button id="go">Run »</button>
</p>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>
<div class="block"></div>