[Solved] How do I find empty cells or cells with &nbsp in td in table and make it editable using js and jquery


Try like this .trim() will ignore the  

$('td').each(function() {
  if (!$(this).text().trim()) {
    $(this).attr('contenteditable', true)
  }
})
table,
tr,
td {
  border: 1px solid #333;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td> </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td></td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td></td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
  <tr><td>one</td><td>&nbsp; &nbsp; &nbsp; </td><tr>
</table>

0

solved How do I find empty cells or cells with &nbsp in td in table and make it editable using js and jquery