Jquery image count elements
I'm working with bjqs slider and fancybox. I'm trying to calculate the
number of images shown and display them as Image 1/3, 2/3, 3/3 etc... At
the moment, the script is showing count, but its not responding to first
click and count number of total images is wrong.
Any help would be appreciated, Here is the code:
<script>
$(function() { $('.toggle').click(function() { $('.col_2').toggle();
return false; }); });
$(window).resize(function(){ if(window.innerWidth > 960) {
$(".col_2").removeAttr("style"); } });
jQuery(document).ready(function($) {
$('#banner-slide').bjqs({
animtype : 'slide',
height : 690,
width : 536,
responsive : true,
randomstart : false,
});
$(".fancybox").fancybox();
//var numImgs = $('#banner-slide img').length - 2;
// $('.count').text(numImgs);
var images = $('#banner-slide img');
var imageIndex = 1;
$("li.bjqs-next a").click(function(){
$('.count').text(imageIndex++ + "/" + images.length/2);
if( imageIndex > images.length/2 )
{
imageIndex = 1;
}
else { }
})
$("li.bjqs-prev a").click(function(){
$('.count').text(imageIndex-- + "/" + images.length/2);
if( imageIndex < 1 )
{
imageIndex = images.length/2;
}
})
// $('ul.bjqs-controls li.bjqs-next a').click( function(){
$('.count').text(($current++) + "/" + $iCount); });
//$('ul.bjqs-controls li.bjqs-prev a').click( function(){
$('.count').text(($current--) + "/" + iCount); });
$('.count').text("1" + "/" + images.length/2);
//setInterval(function () { }, 1000);
});
</script>
No comments:
Post a Comment