javascript - cant get text from an element in jQuery -


i have html setup follows , trying use jquery access textin font field. table has multiple rows, hence first line in jquery, reason i'm getting empty string returned title variable. thank help!

html

<table class="table">     <tbody>         <tr>             <td class="head">                 <a href="link" target="_self">                     <p>                         <font>sometext</font>                     </p>                 </a>             </td>         </tr>     </tbody> </table> 

jquery

$('.table').each(function(){     $(this).filter(function(){         var data   = $(this);         title = data.children(".head").text();         json.array.push({             "title" : title             });     }) }) 

.head not child of .table. .children(".head") not return elements. should use .find instead.

also, .filter seems unnecessary:

$('.table').each(function(){     var data = $(this);     title = data.find(".head").text();     json.array.push({         "title" : title     }); }) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -