There is such a code . In this case, I manually create each cell, fill it in and insert it into a row. But in this case, the label is small. And I thought that when the table will say 10 columns for each to create a cell manually this is not at all a matter ... Actually the question is, how can I add a row to the tablet with "little blood"? Also interested in this question. In this case, I just added text using the textContent method, but if you need to add a button to the table and the cell structure will be:

 <td> <button></button>(или <a></a>) </td> 

How can I add this HTML?

1 answer 1

You can install emmet and simple writing in your development environment:

 table>tr*10>td*5 

and pressing the tab key will create a table with 10 rows and 5 cells in each row.

  <table> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </table> 

With JS you can add this:

 $('table tr:last-child').after('<tr><a href=""></a></tr>') 
  • Um Option is the rules, but this is not the answer. - Eugen Eray
  • one
    The author seems to be asking about the dynamic addition, and not about facilitating static HTML generation during development. - Yaant
  • @olezha $ ('table tr: last-child'). after ('<tr> <a href=""> </a> </ tr>') is not JS, it is jquery. - Vadim