StacyMidget StacyMidget - 1 year ago 98
jQuery Question

If else Jquery for IP number

I'm trying to test to see if my IP number matches with the one specified. I'm new to Javascript, and not sue what's wrong with my code.

$(document).ready(function() {
$.getJSON("", function(data) {
var userIP = (data.ip);
var myIP =;

if (userIP == myIP) {
$("body").html("<p>IP Login Success!</p>");
} else {
$("body").html("<p>Invalid IP!</p>");

<script src=""></script>

How can I make it see if the IP matches the users?

Answer Source


var myIP = "";

You are assigning a literal string to myIP.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download