JSFiddle - React, Tailwind, and code Playground

by apasaja

HTML

<div id="ip">Loading...</div>

<div id="country_code">&nbsp;</div>

<div id="AU">Hello Australia</div>

<div id="NZ">Hello New Zealand</div>

CSS

#NZ {
  text-align: left;
  color: blue;
  display: none;
}

#AU {
  text-align: left;
  color: blue;
  display: none;
}

JavaScript

$(document).ready(function() {
      $.get("http://freegeoip.net/json/", function(response) {
        $("#ip").html("IP: " + response.ip);
        $("#country_code").html(response.country_code);
        var country = response.country_code;
        if (country == 'AU' || country == 'NZ') document.getElementById(country).style.display = "block";
      }, "jsonp");
    }