-
-
Save christian-fei/a7c11a2514b929d6faaf to your computer and use it in GitHub Desktop.
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() { | |
var attributes = {} | |
attributes["IT"] = 'data-amazon-it'; | |
attributes["GB"] = 'data-amazon-gb'; | |
var url = "http://freegeoip.net/json/"; | |
jQuery.getJSON(url, function(data) { | |
var code = data.country_code; | |
jQuery('[data-amazon]').each(function(index, link) { | |
link = jQuery(link); | |
link.attr('href', link.attr(attributes[code])); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment