Obtain Related Div Text with jQuery
问题 After bit of struggling and few valuable suggestions, I've come into a solution that works well as follows: $(document).ready(function(){ divs = $(".divs").children(); divs.each(function(e) { if (e != 0) $(this).hide(); }); $("#next").click(function(){ if (divs.next().length != 0) divs.next().show().prev().hide(); else { divs.hide(); divs.show(); } return false; }); $("#prev").click(function(){ if (divs.prev().length != 0) divs.prev().show().next().hide(); else { divs.hide(); divs.show(); }