Just starting out with FE web development. I've found this image viewer that I really like. Got it to work on my files. However, I'm having issues using the same image viewer multiple times in the same HTML file. Can anyone point me in the direction of what I'm doing wrong?
HTML:
<div id="slider">
<h3>EventGlance UI Mock Ups</h3>
<a href="#" class="control_next">></a>
<a href="#" class="control_prev"><</a>
<ul>
<li><img src="images/1.jpg" height="568" width="320" /></li>
<li><img src="images/2.jpg" height="568" width="320" /></li>
<li><img src="images/3.jpg" height="568" width="320" /></li>
<li><img src="images/4.jpg" height="568" width="320" /></li>
</ul>
</div>
JQuery/JS:
jQuery(document).ready(function ($) {
var slideCount = $('#slider ul li').length;
var slideWidth = $('#slider ul li').width();
var slideHeight = $('#slider ul li').height();
var sliderUlWidth = slideCount * slideWidth;
$('#slider').css({ width: slideWidth, height: slideHeight });
$('#slider ul').css({ width: sliderUlWidth, marginLeft: - slideWidth });
$('#slider ul li:last-child').prependTo('#slider ul');
function moveLeft() {
event.preventDefault();
$('#slider ul').animate({
left: + slideWidth
}, 200, function () {
$('#slider ul li:last-child').prependTo('#slider ul');
$('#slider ul').css('left', '');
});
};
function moveRight() {
event.preventDefault();
$('#slider ul').animate({
left: - slideWidth
}, 200, function () {
$('#slider ul li:first-child').appendTo('#slider ul');
$('#slider ul').css('left', '');
});
};
$('a.control_prev').click(function () {
moveLeft();
});
$('a.control_next').click(function () {
moveRight();
});
});