Created
September 25, 2012 03:36
-
-
Save twright/3779840 to your computer and use it in GitHub Desktop.
Combine images
This file contains 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
jQuery(document).ready(function() { | |
// Add the event listainer to each field | |
addEventListeners('css selector of fields'); | |
}); | |
function changeSrc(img, url) { | |
// Set the src attribute of the image | |
image.attr('src', url); | |
} | |
function addEventListeners(fieldSelector) { | |
// Get all of the fields on the page | |
var fields = jQuery(fieldSelector); | |
// Add the relevant event listainer | |
fields.each(function(index) { | |
$(this).change(function() { | |
changeSrc($(this), getURLForImg($(this).val())); | |
}); | |
}); | |
} | |
function getURLForImg(fieldValue) { | |
// Get the url corresponding to the image | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment