How do you know the 'if' isn't working correctly? It doesn't play? At this point we don't know if the problem is with the 'if' statement itself or with the code inside it. Have you put another alert *inside* the if statement to verify whether it actually gets there or not?
The 'if' statement is pretty fundamental to JavaScript. It doesn't fail. So if something is going wrong, then likely either the value of 'cookie' is not quite what you expect, or the code inside the if isn't working. Could the cookie value have some whitespace in it? You wouldn't see that in an alert. You can check it with things like this: alert( cookie.length ); alert( '{' + cookie + '}' ); -Mike On Thu, Dec 3, 2009 at 4:46 AM, shapper <mdmo...@gmail.com> wrote: > Hello, > > I have the following code: > > alert($.cookies.get("WCA.Player")); > var cookie = $.cookies.get("WCA.Player"); > if (cookie == null || cookie == 'Play') { > $("#JPlayer").play(); > } > > The alert gives me the correct value which is null or 'Play' but the > if is not working correctly. > Am I doing something wrong? > > Thanks, > Miguel > > > > > > >