i using jquery cycle2 plugin http://jquery.malsup.com/cycle2/demo/basic.php
i need grab width of current slide/image , use set width of element.
each image may different width , need bar on top of image resize accordingly.
<div class="cycle-slideshow"> <img src="http://malsup.github.com/images/p1.jpg"> <img src="http://malsup.github.com/images/p2.jpg"> <img src="http://malsup.github.com/images/p3.jpg"> <img src="http://malsup.github.com/images/p4.jpg"> </div> how can width of current/active slide?
you can take hint plugin add class active current active image. can desired width:
var imgwidth = $(".cycle-slideshow").find("img.active").width(); then can use width value set width other element:
$("other element selector").width(imgwidth); edit
i assume html next , prev button this:
<div class="center"> <a href="#" id="prev">prev</a> <a href="#" id="next">next</a> </div> then need do:
$("#prev, #next").on('click', function() { var imgwidth = $('.cycle-slideshow').find(".cycle-slide-active").width(); $(".topbar").width(imgwidth); });
Comments
Post a Comment