Question

Does anybody knows why this snippet returns false even if the passed string is "Active"?

if ($('status_'+id).getText()=="Active")

I've also tried changing the code to

if ($('status_'+id).getText()==String("Active"))

and

if (String($('status_'+id).getText())=="Active")

and still no luck.

I've also checked $('status_'+id).getText() through console.log to verify if it really returns "Active"

i wonder why it doesnt work? any ideas?

Was it helpful?

Solution

Silly question: are you sure the returned string doesn't contain spaces?

OTHER TIPS

The first step in any debugging task is to check your assumptions. Use a debugger or a series of alerts to check the following:

  • what's the value of id?
  • does$('status_'+id) evaluate to a DOM element?
  • what does $('status_'+id).getText() actually return
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top