It's quite easy with an API that maps IP address to location. Run the snippet to get city & country for the IP in the input box.
$('.send').on('click', function(){
$.getJSON('https://ipapi.co/'+$('.ip').val()+'/json', function(data){
$('.city').text(data.city);
$('.country').text(data.country);
});
});
,