I want to display latitude and longitude but he some error come :- Here is my code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hello everyone</h1>
<script>
if ('geolocation' in navigator) {
console.log('gelocation is availabe');
navigator.geolocation.getCurrentPosition((position) => {
const lat=position.coords.latitude;
const lon=position.coords.latitude;
document.getElementById('latitude').textContent=lat;
document.getElementById('longitutde').textContent=lon;
// console.log(position);
});
} else {
console.log('geolocation IS NOT available ');
}
</script>
</body>
</html>
I want to display latitude and longitude