Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
33
rated 0 times [  38] [ 5]  / answers: 1 / hits: 33959  / 13 Years ago, tue, october 4, 2011, 12:00:00

I have a XML file that contains



<car>
<id>123</id>
<sunroof>FALSE</sunroof>
<service>TRUE</service>
</car>


The following code only works if I wrap TRUE inside quotes e.g (service == TRUE)



var service = tis.find(service).text();

if(service === TRUE){
var service_tag = '<a title=Service href=>Service</a>'
} else {
var service_tag = '';
}

More From » jquery

 Answers
21

Without quotes javascript will try to interpret TRUE as a value / expression. There is no value TRUE natively defined in javascript. There is true but javascript is case sensitive so it won't bind TRUE to true.



The value you get back from text() is a string primitive. Writing TRUE gives you back the string TRUE which does compare succesfully with the value service


[#89794] Monday, October 3, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kenyamelinad

Total Points: 339
Total Questions: 85
Total Answers: 116

Location: Marshall Islands
Member since Sun, Aug 29, 2021
3 Years ago
;