mercredi 5 août 2015

Getting elements from table row within different tables with Javascript


i need help with returning some elements from tr with javascript(jquery)

Question 1. How can i reach td where is comment "i need to get to this item (based on question1)"? So i need to get last item with class "b" and first td that comes after it? Number of td's is not static. Classes b may not be in same table.

Question 2. Also if I want to select class "a" and give next 5 (for example) td's some class ("b" for example) how can i do it? Function nextAll can help but it will only get elements from single row.

Example is below:

<table>
<tr>
  <td></td>
  <td></td>
  <td class="a"></td>
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- this needs to get class b -->
</tr>
</table>

<table>
<tr>
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- this needs to get class b -->
  <td></td> <!-- i need to get to this item (based on question1) -->
  <td></td>
  <td></td> 
  <td></td>
</tr>
</table>

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire