What is the best method in jQuery to add an additional row to a table as the last row?
Is this acceptable?
$(\'#myTable\').append(\'
-
jQuery has a built-in facility to manipulate DOM elements on the fly.
You can add anything to your table like this:
$("#tableID").find('tbody')
.append($('')
.append($('')
.append($('')
.attr('src', 'img.png')
.text('Image cell')
)
)
);
The $('')
thing in jQuery is a tag object that can have several attr
attributes that can be set and get, as well as text
, which represents the text between the tag here: text
.
This is some pretty weird indenting, but it's easier for you to see what's going on in this example.
- 热议问题