Skip to content
Advertisement

I need to check if any in a html table is empty/null as in after the page loads it only returns and change it to $0

example of the table

JavaScript

Now the way this is really written, data will be pushed into each td from an API, some times that API is down, and I would like to use jquery to check if a td has anything displaying in it and if it doesnt I want there to be a string with an error message in the td. This is the jquery im trying currently

JavaScript

Advertisement

Answer

  • There is no .trim() in jQuery
  • string trim() is not going to return null.
  • table cells do not have value
  • $(“td”).hasClass(“errorDefault”) only looks at first element

JavaScript
JavaScript
JavaScript

If it is truly empty, CSS can do it.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement