Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
107
rated 0 times [  109] [ 2]  / answers: 1 / hits: 21779  / 12 Years ago, mon, april 2, 2012, 12:00:00

I need to hide the present div and show next hide
here is my codes





$(document).ready(function() {
$('#next').click(function() {
$(this).next().next().children(div).hide();
$(this).next().next().children(div).show();
});
});

#div2,
#div3 {
display: none;
}

<script src=https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js></script>
<button id=prev>Prev</button>
<button id=next>Next</button>
<hr />
<div id=main>
<div id=div1>Div 1</div>
<div id=div2>Div 2</div>
<div id=div3>Div 3</div>
</div>





DEMO


More From » jquery

 Answers
78

Look at this.
Handles start/end using css classes, kept js simple.


[#86463] Saturday, March 31, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jadyngraysons

Total Points: 455
Total Questions: 109
Total Answers: 98

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
jadyngraysons questions
Thu, Apr 23, 20, 00:00, 4 Years ago
Sat, Jan 18, 20, 00:00, 4 Years ago
Tue, Dec 31, 19, 00:00, 5 Years ago
;