jquery - Getting elements from table row within different tables with Javascript -


i need returning elements tr javascript(jquery)

question 1. how can reach td comment "i need item (based on question1)"? need last item class "b" , first td comes after it? number of td's not static. classes b may not in same table.

question 2. if want select class "a" , give next 5 (for example) td's class ("b" example) how can it? function nextall can elements single row.

example below:

<table> <tr>   <td></td>   <td></td>   <td class="a"></td>   <td></td> <!-- needs class b -->   <td></td> <!-- needs class b -->   <td></td> <!-- needs class b --> </tr> </table>  <table> <tr>   <td></td> <!-- needs class b -->   <td></td> <!-- needs class b -->   <td></td> <!-- need item (based on question1) -->   <td></td>   <td></td>    <td></td> </tr> </table> 

thanks

you can

$(document).ready(function() {     $("td.b:last").html(); // content of last td class b       $("td.b:last").next("td").html(); // first td after b class       //       $("td.a:first").slice(5).addclass("b");  });  </script> 

see reference :last , :first , slice()

new edit

  $("table.someclass").each(function(){         $(this).find("td.a:first").nextall("td").addclass("b");     }); 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -