Difference between revisions of "Image slider"

From Organic Design wiki
m
m
Line 38: Line 38:
  
 
// Restructure the content of this sliders div into a table with prev/next buttons
 
// Restructure the content of this sliders div into a table with prev/next buttons
var prev = '<a class="is-prev" href="#">&lt; prev</a>';
+
var prev = '<a class="is-prev" href="javascript:">&lt; prev</a>';
var next = '<a class="is-next" href="#">next &gt;</a>';
+
var next = '<a class="is-next" href="javascript:">next &gt;</a>';
 
div.html( '<table><tr><th><table><tr><td>' + prev + next + '</td></tr></table></th></tr></table>' );
 
div.html( '<table><tr><th><table><tr><td>' + prev + next + '</td></tr></table></th></tr></table>' );
$('.is-prev', div).click(function(e,d) { slide($('div').has(this), -1 ); });
+
$('.is-prev', div).click(function() { slide($('div').has(this), -1 ); });
$('.is-next', div).click(function(e) { slide($('div').has(this), 1 ); });
+
$('.is-next', div).click(function() { slide($('div').has(this), 1 ); });
  
 
// Set the cell size to the image size and other css styles
 
// Set the cell size to the image size and other css styles

Revision as of 23:55, 30 March 2015

Here's a simple image slider written 100% in JavaScript and jQuery. In converts any div elements of class "image-slider" containing img elements in a slider like the one below.

The code is in our Subversion repository here.

Butterfly3.jpg YellowButterfly.jpg MonarchOnPinkTree3.jpg Butterfly1.jpg

Butterfly3.jpg YellowButterfly.jpg MonarchOnPinkTree3.jpg Butterfly1.jpg