Skip to content

Instantly share code, notes, and snippets.

@christian-fei
Forked from pdincau/gist:0825ad51adbcd52ee83c
Last active August 29, 2015 14:22
Show Gist options
  • Save christian-fei/a7c11a2514b929d6faaf to your computer and use it in GitHub Desktop.
Save christian-fei/a7c11a2514b929d6faaf to your computer and use it in GitHub Desktop.
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