jquery - Javascript - Offest div each time element is clicked -
i have been struggling simple issue little frustrating. need div move more right each time button clicked.
<div class="gallery"> //gallery content here </div> <div class="arrow-m-left" onclick="moveleft()"> //button move gallery left 590px each time clicked. </div> <div class="arrow-m-right" onclick="moveright()"> //button move gallery right 590px each time clicked. </div>
you can achieve of jquery .animate().
here example
reference here
html
<button id="left">«</button> <button id="right">»</button> <div class="block"></div>
css
div { position: absolute; background-color: #abc; left: 50px; width: 90px; height: 90px; margin: 5px; }
js
$( "#right" ).click(function() { $( ".block" ).animate({ "left": "+=50px" }, "slow" ); }); $( "#left" ).click(function(){ $( ".block" ).animate({ "left": "-=50px" }, "slow" ); });
you can change value of left according need. hope helps.
Comments
Post a Comment