Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.3.min.js " type="text/javascript"></script>
<script src="/Script.js " type="text/javascript"></script>
<script src="/Script2.js " type="text/javascript"></script>
</head>
<body>
<div id="lat"></div>
<div id="long"></div>
</body>
</html>
// this will be placed in Script.js
// latitude
(function ($) {
$.fn.GetLat = function () {
$.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?')
.done(function (location) {
localStorage.setItem("latitude", location.latitude);
});
$(this).text(localStorage.getItem("latitude"));
localStorage.removeItem("latitude");
return this;
};
})(jQuery);
// longitude
(function ($) {
$.fn.GetLong = function () {
$.getJSON('https://geoip-db.com/json/geoip.php?jsonp=?')
.done(function (location) {
localStorage.setItem("longitude", location.longitude);
});
$(this).text(localStorage.getItem("longitude"));
localStorage.removeItem("longitude");
return this;
};
})(jQuery);
// this will be placed in Script2.js
$(document).ready(function () {
$("#lat").GetLat();
$("#long").GetLong();
});
The most helpful JQUERY solutions
plugin get client ip address using jqueryJQUERY Click to see more ... 10.5K 1.8K