get ip addresss using javascript code example
Example 1: how to get user ip address in javascript
<script>
function getIP(json) {
alert("My public IP address is: " + json.ip);
}
</script>
<script src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
<script type="application/javascript" src="https://api.ipify.org?format=jsonp&callback=getIP"> </script>
Example 2: javascript ip address
$.getJSON('https://ipgeolocation.abstractapi.com/v1/?api_key=<your_api_key>', function(data) {
console.log(JSON.stringify(data, null, 2));
});