Getting Geolocation in Weather App

hello!
I am working on weather app. my current code status is- “https://codepen.io/karanatwal/pen/YxxVbZ”.
I am not getting geolocation. Can anyone help me out with this?

I found two problems:

  1. You haven’t imported jQuery.

  2. The function you’re trying to call does not exist. Try the following instead:

      if(navigator.geolocation){   navigator.geolocation.getCurrentPosition(function(position){
       $("#location").html("latitude: "+position.coords.latitude+"<br>longitude: "+position.coords.longitude);
1 Like