Xeptor Xeptor - 23 days ago 6
jQuery Question

Hide element with Javascript based in IP-Adress

Im trying to hide an element based on an IP-adress.

With this script I can write out the IP-adress in the DOM:

<script type="text/javascript" src="https://l2.io/ip.js?var=userip"></script>
<script type="text/javascript">document.write("Your IP is :", userip)</script>


How Do I target this to remove the element below based on a specific IP-address?


Answer

just use document ready and check the ip. IF it matches the condition do your stuff

    var ip=['123.123.123','111.111.11']
     $(document).ready(function () {
if(ip.indexOf(userip)!=-1)
{ your  code here
}
});