How to add a new row to an HTML table using jQuery?
Hello everyone! I'm new to JavaScript and jQuery, and I've encountered a problem while working with HTML tables. I have a simple table where I need to dynamically add rows when a button is clicked. I've tried several methods, but nothing works as expected.
Here's my code:
```html
```
```javascript
$('#addRow').click(function() {
// I tried this:
$('#myTable').append('New 30 ');
// And this:
$('#myTable tr:last').after('New 30 ');
});
```
The problem is that the row
| Name | Age |
|---|---|
| Ivan | 25 |
No answers yet.
Log in to leave an answer