Im learning javascript right now, so this might be a really newb question! I googled it, but didnt found what I was looking for, maybe I just didnt googled the right thing, but yeah…Oh im not using any plug-ins for cookies.
I have a cookie named “country”, the value is the user’s country code, like US, CA, UK, AU or FR…
I want to display a block of content only if the country is, let’s say DE, ES, AT, IT or NL.
The logic of what im looking for: if cookie “country” exist and country == one of the country in my array…
Im thinking about something like… But that is obviously too simple and not working 🙂
var countryArray = new Array["DE", "ES", "AT", "IT", "NL"];
if( $.cookie('country') && $.cookie('country') == countryArray ) { alert("working"); }
You could use indexOf for new browsers:
Also , instead of
you need to write:
UPDATE: For old browsers include this script in your
js: