jquery - Get value inside span tag in second td element in row -


how can value in span tag in second td element of series of table rows?

here example of 1 of table rows:

<tr onfocus="if (window.hion){hion(this);}" onblur="if (window.hioff){hioff(this);}" onmouseout="if (window.hioff){hioff(this);}" onmouseover="if (window.hion){hion(this);}" class="datarow first"> <td colspan="1" id="j_id0:theform:selectedlist:thetable:0:leadname" class="datacell">     <span id="j_id0:theform:selectedlist:thetable:0:j_id93">shelia abraham</span> </td> <td colspan="1" id="j_id0:theform:selectedlist:thetable:0:solutioninterest" class="datacell">     <span id="j_id0:theform:selectedlist:thetable:0:j_id94">birst</span> </td> </tr> 

i want value span tag in second td element each row. in example above, value birst.

here jquery:

    j$(document).ready(function(){           var datarows = j$('tr.datarow');         datarows.each(function(index, elem) {             console.log(index);             console.log(elem);         });              }); 

thanks help.

try use :nth-child(n) @ context, , keep in mind :nth-child(n) index starts 1 not 0

$('tr.datarow td:nth-child(2) span').each(function(){   // code here }); 

demo

and if want grab values in array use .map(),

var spanvalues = $('tr.datarow td:nth-child(2) span').map(function(){    return $(this).text(); }).get(); 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -