jquery 添加表格一行

pylist 84

jquery 添加表格一行

<table id="tblEntAttributes">
    <tbody>
        <tr>
            <td>
                first
            </td>
            <td>
                second
            </td>
        </tr>
        <tr>
            <td>
                third
            </td>
            <td>
                fourth
            </td>
        </tr>
    </tbody>
</table>

<button id="test">appendTo</button>
<button id="test2">append</button>

<script>
var newRowContent = "<tr><td>newcontent</td><td>newcontent2</td></tr>";

$("#test").click(function(){    
    $(newRowContent).appendTo($("#tblEntAttributes"));
});
$("#test2").click(function(){    
   $("#tblEntAttributes tbody").append(newRowContent);
});

</script>
登录发表评论

桂公网安备 45122402000014号