Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript-每次单击元素时提供的div_Javascript_Jquery_Css - Fatal编程技术网

Javascript-每次单击元素时提供的div

Javascript-每次单击元素时提供的div,javascript,jquery,css,Javascript,Jquery,Css,我一直在努力解决一个有点令人沮丧的简单问题。我需要一个div,以便在每次单击按钮时向右移动更多 <div class="gallery"> //Gallery content here </div> <div class="arrow-m-left" onClick="moveLeft()"> //Button to move the gallery left by 590px each time this is clicked. &l

我一直在努力解决一个有点令人沮丧的简单问题。我需要一个div,以便在每次单击按钮时向右移动更多

<div class="gallery">
  //Gallery content here 
</div>
<div class="arrow-m-left"  onClick="moveLeft()">
        //Button to move the gallery left by 590px each time this is clicked.
</div>
<div class="arrow-m-right" onClick="moveRight()">
        //Button to move the gallery right by 590px each time this is clicked.
</div>

//这里是图库内容
//每次单击此按钮时,将库向左移动590px。
//按钮,每次单击时将库向右移动590px。

您可以在jquery.animate()的帮助下实现这一点

这是你的电话号码

参考是

HTML

JS


您可以根据需要更改left的值。希望这有帮助。

谢谢!这正是我要找的!很高兴知道。如果答案有帮助,请接受!我会的,必须先等4分钟!您的
moveLeft()
moveRight()
方法声明在哪里?问题现在已经得到了回答,我将继续使用onclick。
<button id="left">&laquo;</button>
<button id="right">&raquo;</button>
<div class="block"></div>
div {
    position: absolute;
    background-color: #abc;
    left: 50px;
    width: 90px;
    height: 90px;
    margin: 5px;
  }
$( "#right" ).click(function() {
  $( ".block" ).animate({ "left": "+=50px" }, "slow" );
});

$( "#left" ).click(function(){
  $( ".block" ).animate({ "left": "-=50px" }, "slow" );
});