Multiple comparisons in an if statement using the logical OR operator is not workin in JavaScript -
i checking in next way, not working. when using single statement working. i.e (nodename !== "active")
thanks..
function clientcandidatemenunodeclicked(sender, eventargs) { var node = eventargs.get_node(); var nodename=node.get_text(); if( (nodename !== "active") || (nodename !== "recently added") || (nodename !== "added") ) { if (nodename != null) { alert(nodename); } } node.toggle(); }
your logic wrong. if value of nodename
"recently added"
first thing happens comparing "active"
evaluates true
(because not same). because first status evaluates true whole status considered true , alert
executed.
you need alter "ors" "ands" (notice i've removed parentheses too... don't need them here):
if (nodename !== "active" && nodename !== "recently added" && nodename !== "added") { // stuff }
javascript
No comments:
Post a Comment