Created
August 27, 2012 13:16
-
-
Save LL782/3488337 to your computer and use it in GitHub Desktop.
Image Source Swapping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
</head> | |
<body> | |
<div id="imgSection"> | |
<div id="image-thumbs"> | |
<a href="img_1_large.png"><img src="img_1_thumb.png" /></a> | |
<a href="img_2_large.png"><img src="img_2_thumb.png" /></a> | |
<a href="img_3_large.png"><img src="img_3_thumb.png" /></a> | |
</div><!-- #image-thumbs --> | |
<div id="main-image"> | |
<img src="img_1_large.png" /> | |
</div><!-- #main-image --> | |
</div><!-- imgSection --> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script src="imgSrcSwapping.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
/* | |
IMG SRC SWAPPING | |
*/ | |
var $imgSection = $('#imgSection'); | |
if ( $imgSection.length ) { | |
$('#image-thumbs a', $imgSection).click(function(e){ | |
e.preventDefault(); | |
var src = $(this).attr('href'); | |
$('#main-image img').attr( 'src', src ); | |
}); | |
} // end if | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment