show content by country lookup - switch content

by ian_smithz

HTML

<!-- <div id="ip">Loading...</div> -->
<div id="country_code"></div>

<div class="hide GB">Hello Great Britain</div>
<div class="hide DE">Hallo Deutschland</div>
<div class="hide FR">Bonjour Madam</div>

<!--

other services

http://ipinfo.io

-->

CSS

.hide {display: none;}

JavaScript

$.get("http://freegeoip.net/json/", function (response) {
	//$("#ip").html("IP: " + response.ip);
	$("#country_code").html(response.country_code);
    document.getElementsByClassName(response.country_code)[0].style.display = "block";
}, "jsonp");

//document.getElementById("US").style.display = "block";
//document.getElementById("CA").style.display = "block";