Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wanted to add new row using jQuery.

Like this:

<table border="1">
    <tr>
        <th>id</th>
        <th>name</th>
        <th>description</th>
    </tr>
    <tr>
        <td>1</td>
        <td>einlanzer</td>
        <td>dev</td>
    </tr>
</table>
<input type="button" id="addme" value="add">
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
248 views
Welcome To Ask or Share your Answers For Others

1 Answer

insertAfter: This will insert the element after the specified element.

$('<tr />').insertAfter('table tr:last');

Docs: http://api.jquery.com/insertAfter/

append: Will append to the end of the element.

$('table').append('<tr></tr>');

Docs: http://api.jquery.com/append/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...