How to get ip address in jquery?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Sometimes we need to get ip address by using jquery. Today now in this post i will show you how to get ip address in jquery? We can easily get ip address in jquery by using getJSON(). If we need to get the ip address in our js file the we can use getJSON() and get ip address easily. So now in this example you can see how we can catch ip address in jquery code section.

So let’s start and try with this.

Example
<html lang="en">
<head>
    <title>Jquery - get ip address</title>
    <script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
</head>
<body>

<h1>Your Ip Address : <span class="ip"></span></h1>


<script type="text/javascript">
	$.getJSON("http://jsonip.com?callback=?", function (data) {
	    $(".ip").text(data.ip);
	});
</script>


</body>
</html>

Read Also : Laravel 8 Mobile Number Verification Tutorial

Thanks for read. I hope it help you. For more you can follow us on facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →