-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
  • 15,221
  • 39
  • 109
  • 166

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
  • 867
  • 1
  • 11
  • 23
0
$('#table1 tr').find('td').eq(0).html() == '&nbsp;'

solved the above issue

user544079
  • 15,221
  • 39
  • 109
  • 166
-1

Try to check:

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

The trim() will help you here.

Naveen Chandra Tiwari
  • 4,895
  • 2
  • 18
  • 26