Home  >  Q&A  >  body text

javascript - <td>' + result[dateNow]?result[dateNow]:'无课'+ '</td>'

Can I write my ternary expression like this? It’s useless if I write it
result is the fetched data, I want to append this to html
I want to judge whether it is empty, for If empty, it will display "No Class"

PHP中文网PHP中文网2710 days ago631

reply all(2)I'll reply

  • 某草草

    某草草2017-05-19 10:35:07

    If the content of result[dateNow] is empty, according to your expression, it will not die in the end. "No class" should return empty
    Unless result[dateNow] returns undefined, your expression can display "No class" Bar

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-19 10:35:07

    Initially, there seems to be no problem. Please help to complete the code involved in the problem, thank you.

    reply
    0
  • Cancelreply