📅  最后修改于: 2022-03-11 15:04:10.189000             🧑  作者: Mango
$("#find_btn").click(function () { //user clicks button
if ("geolocation" in navigator){ //check geolocation available
//try to get user current location using getCurrentPosition() method
navigator.geolocation.getCurrentPosition(function(position){
$("#result").html("Found your location
Lat : "+position.coords.latitude+" Lang :"+ position.coords.longitude);
});
}else{
console.log("Browser doesn't support geolocation!");
}
});