I’m using navigator for the weather app assignment, to get started I used the code I learned from the previous exercise. Here’s the code snippet of my window load function so far:
$(window).load(function ( {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
$("#data").html("latitude: " + position.coords.latitude + "<br>longitude: " + position.coords.longitude);
lat = position.coords.latitude;
lon = position.coords.longitude;
});
}
});
Lat is a variable for latitude, lon is a variable of longitude, and the $("#data") section will be removed and replaced with weather app related code. Anyway, the problem is: if (navigator.geolocation) {, the error is: Uncaught SyntaxError: Unexpected token .
Any help is appreciated.