html - jQuery not finding inputs in table cells -


i have strange issue table cell value.

my html like:

<table>    <tr>       <td> celll </td>       <td> celll </td>       <td> celll </td>    </tr>    <tr>       <td> celll </td>       <td> <input type='text'> </td>       <td> <input type='text'> </td>    </tr> </table> 

i want replace cell has input tag.

so i:

 $('table').find('td').each(function(){       if($(this).text()==''){           console.log('found input')          }   }) 

however, can't seem find codes.

any tips here?

$.text() method gets combined text contents of each element , returns white spaces or new-lines.

so trim string using $.trim method:

$('table').find('td').each(function() {   if($.trim($(this).text()) === ''){     console.log('found input');     } }); 

jsbin demo

update

another option using .find() method again example below, but according jsperf test, using jquery 1.8.x, has lower performance:

$('table').find('td').each(function() {   if($(this).find('input').length){     console.log('found input');     } }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -