My goal is to create a JavaScript functionality where clicking on a button reveals the next div, followed by subsequent ones. Essentially, it's a 'next' button with the option for a 'previous' button as well.
I've exhausted all my options and can't seem to crack the solution. Any advice or assistance would be greatly appreciated, thank you!
If anyone can offer some help, please?
<div id="wrapper">
<div class="featured">
<input id="button-next" type="button" value="next"/>
<img src="photos/bookcover/Alluredbyyou.jpg" alt="" srcset="">
<p>ALLURED BY YOU</p>
<span>Lorem text part 1</span>
</div>
<div class="featured2">
<input id="button-next" type="button" value="next"/>
<img src="photos/bookcover/Notyourmarrysue.jpg" alt="" srcset="">
<p>Rebecca Frost</p>
<span>Lorem text part 2</span>
</div>
</div>
<script>
$(document).on('click','#button-next', function() {
$('.featured').removeClass('featured2').next('.featured').addClass('active');
});
</script>
.featured, .featured2 {
float: left;
margin-left: 16%;
margin-top: 4%;
width: 980px;
height: 450px;
background-color: #CFD0CD;
}
.featured img, .featured2 img {
width: 230px;
height: 360px;
margin-top:4%;
margin-left: 5%;
float: left;
}
.featured p, .featured2 p{
float: right;
margin-top: 5%;
margin-bottom: 0%;
margin-right: 51%;
width: 18%;
font-size: 20px;
font-family:'poppins';
text-align: left;
}
.featured span, .featured2 span {
float: right;
margin-top: 0%;
margin-right: 4%;
width: 65%;
font-size: 18px;
font-family: Arial, Helvetica, sans-serif;
height: 75%;
text-align: left;
word-wrap: break-word;
word-break:normal;
line-height: 30px;
white-space: inherit;
}
#button-next{
color: #000000;
float: right;
font-size: 19px;
border: 3px solid #000000;
padding: 5px 50px;
margin-right: 0%;
margin-top: 0%;
letter-spacing: 1px;
cursor: pointer;
transform: scale(1.0);
transition: ease-in-out 0.5s;
}
#button-next:hover {
transform: scale(0.9);
transition: ease-in-out 0.5s;
}