Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery get location of user

$("#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 <br />Lat : "+position.coords.latitude+" </br>Lang :"+ position.coords.longitude);
			});
	}else{
		console.log("Browser doesn't support geolocation!");
	}
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: js string contains substring ignore case 
Javascript :: regex pattern to validate email 
Javascript :: jquery ajax while loading 
Javascript :: node js unix timestamp 
Javascript :: round number 2 decimal places javascript 
Javascript :: p5.js add class to button 
Javascript :: moment set hours 
Javascript :: get value before change and after change js 
Javascript :: how to get xhr response in javascript 
Javascript :: regex ranges 
Javascript :: Found multiple occurrences of org.json.JSONObject on the class path: 
Javascript :: get document height js 
Javascript :: pass an array to javascript in asp net core list 
Javascript :: copy to clipboard javascript 
Javascript :: strapi login api 
Javascript :: react state add to array 
Javascript :: vue js default prop 
Javascript :: image onclick function react 
Javascript :: web3.js get balance 
Javascript :: angular string contains 
Javascript :: moment js year only 
Javascript :: navigate-to-an-anchor-on-another-page 
Javascript :: jquery remove click event 
Javascript :: add property to string js 
Javascript :: remove console log in production react 
Javascript :: vue chart nuxt 
Javascript :: exit extension from chrome javascript 
Javascript :: express get query params from url 
Javascript :: how to detect account change in metamask 
Javascript :: difference between devDependency and dependency 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =