开发者

Can someone help me with an if statement? The result is true, but the event will not fire

开发者 https://www.devze.com 2023-03-27 16:57 出处:网络
I am retrieving data that displays a value of true in the console, but when I set up an if statement

I am retrieving data that displays a value of true in the console, but when I set up an if statement

i开发者_JS百科f (onLive == true) {
 alert ("is working")
 }

the alert does not fire. Can anyone help me? Here is the code http://jsfiddle.net/8j947/


isLive is "true" (a string containing the word true), not true (a boolean value).


Works like this: http://jsfiddle.net/8j947/3/

You forgot to insert jQuery. And isLive returns 'true' a string, not a boolean! You can check it like this:

if (isLive == 'true') {
      alert('working');
}


the var isLive specifically needs to compare boolean values. In this case, you might want to check what type it is comparing. I am quite sure that it is not a bool comparison. Secondly, as previously mentioned, the statement can be if(isLive=='true') { .... } Hope This Helps

0

精彩评论

暂无评论...
验证码 换一张
取 消