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">&laquo;</button> <button id="right">&raquo;</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

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -