jQuery get shown div id
I have the following code:
<div class="sequence-container">
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
</div>
and jQuery:
$(window).load(function(){
$('.sequence-container div:first').show(); // show first on load
$('.next').click(function() {
var $next = $('.sequence-container div:visible').next();
if ($next.length) {
$('.sequence-container div').hide();
$next.show();
}
});
$('.prev').click(function() {
var $prev = $('.sequence-container div:visible').prev();
if ($prev.length) {
$('.sequence-container div').hide();
$prev.show();
}
});
});
This, very nicely, allows a user to move back and forth through divs.
However, what I'd like to do, is bring back the ID of the div that is
currently being shown. I'm struggling - any suggestions?
No comments:
Post a Comment