<script> var x = document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { x.innerHTML = "Geolocation is not supported by this browser."; } } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script>
In x.innerHTML = "Latitude:
How I do change the value?
Nice question.
What type of control demo is? If it's label or text box you can set the value using value property. Inner html property is used to set the Html NOT value.