📌  相关文章
📜  jquery 获取用户的位置 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:10.189000             🧑  作者: Mango

代码示例1
$("#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!"); } });