Weather App Help needed z

See the Pen Weather App by Eldar (@eldarm) on CodePen.

hi guyz, it just first step, wanna to get geo location , then will pass it. But is not giving latt. and long. properly. Just copied exact code from tutorial of FCC

You need to add jQuery separately (Settings > JavaScript > Quick-add: jQuery). Also, you need quotes around button: $("button") instead of $(button).

1 Like

Apart from what @BenGitter mentioned, you should also wrap your $("button").on("click", findLocation); line inside .ready function like

$(document).ready(function(){
  $("button").on("click", findLocation);
})

you mean like this?

$(document).ready(function(){

function findLocation() {
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    $("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
  });
  
  $.getJSON( "https://fcc-weather-api.glitch.me/", function( data ) {
  var items = [];
  $.each( data, function( lon, lat ) {
    items.push( "<li id='" + lon + "'>" + lat + "</li>" );
  });
 
  $( "<ul/>", {
    "lon": "my-new-list",
    html: items.join( "" )
  }).appendTo( "#data" );
});
  
}
  return false;
}

$("button").on("click", findLocation);

})
why?