-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

7
  • 1
    @user3292653: This is a different question with a different problem. Please read the question again. Commented May 9, 2014 at 12:24
  • How are you transferring the file to the server? What does insert the garbage? Commented May 9, 2014 at 12:24
  • stackoverflow.com/questions/154059/… Commented May 9, 2014 at 12:24
  • @PatrickHofman: Maybe not too soon Commented May 9, 2014 at 12:24
  • 1
    @user544079: You need to explain in the question more about "While transferring the file to server..." and "...each time I deploy on server". Commented May 9, 2014 at 12:40

3 Answers 3

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");
Sign up to request clarification or add additional context in comments.

Comments

0
$('#table1 tr').find('td').eq(0).html() == '&nbsp;'

solved the above issue

Comments

-1

Try to check:

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

The trim() will help you here.

2 Comments

the cell contains a &nbsp;. So length comes out 1. How to check for &nbsp;
Please try this. $.trim() will remove the extra space. Have you tried this code?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.