Team:UNITN-Trento/JS/Team
From 2013.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
function swapBg(img) { | function swapBg(img) { | ||
- | |||
alt = $(img).attr('data-alt'); | alt = $(img).attr('data-alt'); | ||
src = $(img).attr('src'); | src = $(img).attr('src'); | ||
- | |||
$(img).fadeOut('fast', function() { | $(img).fadeOut('fast', function() { | ||
- | |||
$(img).attr('src',alt); | $(img).attr('src',alt); | ||
$(img).attr('data-alt',src); | $(img).attr('data-alt',src); | ||
$(img).fadeIn(); | $(img).fadeIn(); | ||
- | |||
}); | }); | ||
- | |||
} | } | ||
Line 17: | Line 12: | ||
$( '#jms-slideshow' ).jmslideshow(); | $( '#jms-slideshow' ).jmslideshow(); | ||
- | $('#jms-slideshow .image | + | $('#jms-slideshow .image').each(function() { |
$(this).mouseenter(function(e) { | $(this).mouseenter(function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
- | swapBg(this); | + | swapBg($(this).children('img')); |
}); | }); | ||
}); | }); | ||
- | $('#jms-slideshow .image | + | $('#jms-slideshow .image').each(function() { |
$(this).mouseleave(function(e) { | $(this).mouseleave(function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
- | swapBg(this); | + | swapBg($(this).children('img')); |
}); | }); | ||
}); | }); | ||
}); | }); |
Revision as of 12:36, 12 August 2013
function swapBg(img) { alt = $(img).attr('data-alt'); src = $(img).attr('src'); $(img).fadeOut('fast', function() { $(img).attr('src',alt); $(img).attr('data-alt',src); $(img).fadeIn(); }); }
$(document).ready(function() { $( '#jms-slideshow' ).jmslideshow();
$('#jms-slideshow .image').each(function() { $(this).mouseenter(function(e) { e.preventDefault(); swapBg($(this).children('img')); }); }); $('#jms-slideshow .image').each(function() { $(this).mouseleave(function(e) { e.preventDefault(); swapBg($(this).children('img')); }); }); });