-1

I have

<table id="table1">
 <tr>
   <td>&nbsp;</td>
 </tr>
</table>

I check for the value in using

$('#table1 tr').find('td').eq(0).text()

this equates to " "

so the check is

$('#table1 tr').find('td').eq(0).text() == " "

While transferring the file to server, a garbage value is inserted between quotes

$('#table1 tr').find('td').eq(0).text() == " A "

using $('#table1 tr').find('td').eq(0).text().trim() also gives " " as the cell contains &nbsp;

How do I prevent this garbage value from being inserted each time I deploy on server

user544079
  • 16,109
  • 42
  • 115
  • 171

3 Answers3

0

Instead of text(), try to set HTML().

Try this, for setting value in Table Cell (TD).

$('#table1 tr').find('td').eq(0).html("A");
Dharam Mali
  • 907
  • 1
  • 11
  • 24
0
$('#table1 tr').find('td').eq(0).html() == '&nbsp;'

solved the above issue

user544079
  • 16,109
  • 42
  • 115
  • 171
-1

Try to check:

$.trim($('#table1 tr').find('td').eq(0).text()).length

The trim() will help you here.

Naveen Chandra Tiwari
  • 5,055
  • 3
  • 20
  • 26