Pops wrote:
> I think I have a "theory" about why this is happen and it might not be
> jQuery related but just Javascript, but maybe someone can explain this
> because it is so odd.
> 
> This is the code:
> 
>   logln("wcError "+IsHidden('wcError')?"hidden":"not hidden");
> 
> logln() is a function tha basically appends text to a log window.
> However, I don't see
> 
>       "wcError hidden"  or  "wcError not hidden"
> 
> but rather:
> 
>       " hidden"  or  "not hidden"
> 
> in other words, the left side string "wcError " is not concentated.
> 
> But the following works:
> 
>   s = IsHidden('wcError')?"hidden":"not hidden"
>   logln("wcError "+s);
> 
> or this by enclosing it with ()
> 
>   logln("wcError "+(IsHidden('wcError')?"":"not ")+"hidden");
> 
> but not this (without parenthesis)
> 
>  logln("wcError "+IsHidden('wcError')?"":"not "+"hidden");
> 
> IsHidden() just returns true or false
> 
> function IsHidden(s) {
>    var e = document.getElementById(s);
>    return !e?true:e.style.display != "block";
> }
> 
> Anyway, logln() was first a jQuery method for my plugin and in trying
> to see what is going I am made it strictly DOM so I see it isn't
> jQuery related.
> 
> What am I missing here?  Something about how JS sees strings that I am
> missing here.

That is a matter of operator precedence. The plus operator has higher 
precedence than the conditional operator, thus

"wcError "+IsHidden('wcError')

gets evaluated first, afterwards the ?:

http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Operators:Operator_Precedence



--Klaus



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery (English)" group.
To post to this group, send email to jquery-en@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-en?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to