JSFiddle - React, Tailwind, and code Playground
by gbsandeep
HTML
<script>
function getLocation()
{
var x=document.getElementById("demo");
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
var x=document.getElementById("demo");
x.innerHTML="Latitude: " + position.coords.latitude +
"<br />Longitude: " + position.coords.longitude;
}
</script>
<p id="demo">Click the button to get your coordinates:</p>
<button onClick="javascript:getLocation()">Try It</button>