Team:UNITN-Trento/JS/Team
From 2013.igem.org
Line 27: | Line 27: | ||
div = $('<div/>'); | div = $('<div/>'); | ||
$(div).addClass( 'tn-hoverTag' ); | $(div).addClass( 'tn-hoverTag' ); | ||
- | $(div).html( '<img src="' + $(_self).attr(' | + | $(div).html( '<img src="' + $(_self).attr('href') + '" />' ); |
alert(2); | alert(2); | ||
$(div).click(function(e) { | $(div).click(function(e) { |
Revision as of 07:45, 13 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).click(function(e) { e.preventDefault(); swapBg($(this).children('img')); }); });
$('#tn-content .tag').each(function() { $(this).click(function(e) { e.preventDefault(); if ( $(this).attr( 'data-type' ) === "img" ) { _self = $(this); alert(1); div = $('<div/>'); $(div).addClass( 'tn-hoverTag' ); $(div).html( '<img src="' + $(_self).attr('href') + '" />' ); alert(2); $(div).click(function(e) { e.preventDefault(); $(div).remove(); alert(3); }); $('body').append(div); alert(4); } else { alert("E"); } }); }); });