Template:Team:UC Davis/imageSlider
From 2014.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
<html> | <html> | ||
<head> | <head> | ||
- | |||
<style> | <style> | ||
Line 70: | Line 69: | ||
} | } | ||
</style> | </style> | ||
- | <script src="//ajax.googleapis.com/ajax/libs/jquery/ | + | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> |
<script type='text/javascript'> | <script type='text/javascript'> | ||
- | $(document).ready(function(){ | + | <script type="text/javascript"> |
+ | /* <![CDATA[ */ | ||
+ | ( function( $ ) { | ||
+ | $( 'a[href="#"]' ).click( function(e) { | ||
+ | e.preventDefault(); | ||
+ | } ); | ||
+ | } )( jQuery ); | ||
+ | /* ]]> */ | ||
+ | </script> | ||
+ | |||
+ | jQuery(document).ready(function ($) { | ||
$('#checkbox').change(function(){ | $('#checkbox').change(function(){ |
Revision as of 22:50, 14 October 2014
jQuery(document).ready(function ($) { $('#checkbox').change(function(){ setInterval(function () { moveRight(); }, 3000); }); 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() { $('#slider ul').animate({ left: + slideWidth }, 200, function () { $('#slider ul li:last-child').prependTo('#slider ul'); $('#slider ul').css('left', ''); }); }; function moveRight() { $('#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(); }); });