JSFiddle - React, Tailwind, and code Playground

http://stackoverflow.com/questions/17064433/show-hide-divs-using-next-previous-button-using-jquery

HTML

<div class="mydivs">
    <div>Question 1</div>
    <div>Question 2</div>
    <div>Question 3</div>
    <div>Question 4</div>
    <div>Question 5</div>
    <div>Question 5</div    
</div>
<button name="prev">Prev</button>
<button name="next">Next</button>

CSS

.mydivs {
    height:300px;
    border:5px solid #ccf;
}
.mydivs>div {
    height:100%;
    overflow-y:auto;
    border:5px solid #ff0;
    padding:1em;
    box-sizing:border-box;
    -moz-box-sizing:border-box;
}

JavaScript

$(document).ready(function () {
    var divs = $('.mydivs>div');
    var now = 0; // currently shown div
    divs.hide().first().show();
    $("button[name=next]").click(function (e) {
        divs.eq(now).hide();
        now = (now + 1 < divs.length) ? now + 1 : 0;
        divs.eq(now).show(); // show next
    });
    $("button[name=prev]").click(function (e) {
        divs.eq(now).hide();
        now = (now > 0) ? now - 1 : divs.length - 1;
        divs.eq(now).show(); // or .css('display','block');
        //console.log(divs.length, now);
    });
});