Hi friends, I'm trying to make a footbridge of images, well I'm doing it in the following way a div with overflow-x: sroll; , inside the div 5 or 6 images that when clicking a button, they go through and then hiding the scroll and then move it through the jquery so that the images move as well. up here everything is fine but when I try to move the scroll to the right it does not move and I do not understand why I leave here my code of what I am doing I hope you can help me
$(document).ready(function(){
$(".button1").click(function(){
$(".cop").animate({scrollLeft: "+=305"}, 500);
});
$(".button2").click(function(){
$(".cop").animate({scrollRight: "+=305"}, 500);
})
})
.cop{
width:300px;
height:300px;
background:white;
position:relative;
overflow-x:scroll;
overflow:hidden;
}
.corp{
width:auto;
height:auto;
display:flex;
}
.corp img{
margin-left:5px;
}
.button1{
position:absolute;
left:0;
bottom:0;
}
.button2{
position:absolute;
right:0;
bottom:0;
}
button{
background:rgba(245,225,155,0.7);
border-radius:5px;
padding:3px;
border:none;
}
button:hover{
cursor:pointer;
padding:5px;
background:rgba(255,255,255,0.9);
}
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Menú Principal</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</head>
<body>
<div style="position:relative; max-width:300px;">
<div class="cop">
<div class="corp">
<img src="newzoneg.png" width="300px" height="300px">
<img src="newzoneg.png" width="300px" height="300px">
<img src="newzoneg.png" width="300px" height="300px">
<img src="newzoneg.png" width="300px" height="300px">
<img src="newzoneg.png" width="300px" height="300px">
<img src="newzoneg.png" width="300px" height="300px">
<img src="newzoneg.png" width="300px" height="300px">
</div>
</div>
<button class=" mt-5 button1">LEFT</button>
<button class="mt-5 button2">RIGHT</button>
</div>
</body>
</html>