Skip to content

Instantly share code, notes, and snippets.

@pdincau
Last active August 29, 2015 14:22
Show Gist options
  • Save pdincau/0825ad51adbcd52ee83c to your computer and use it in GitHub Desktop.
Save pdincau/0825ad51adbcd52ee83c to your computer and use it in GitHub Desktop.
amazon links
var url = "http://freegeoip.net/json/ ";
jQuery.getJSON(url, function(data) {
var code = data.country_code;
var links = jQuery('[data-amazon]');
jQuery.each(links, function(index, link) {
var el = jQuery(link);
if (code == "IT") {
el.attr('href', el.attr('data-amazon-it'));
}
if (code == "GB") {
el.attr('href', el.attr('data-amazon-gb'));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment