HTML5   发布时间:2022-04-25  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html5 contenteditable 实现table可编辑大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<!doctype html>
<html>
<head>
    <title>table contenteditable</title>
    <script type="text/javascript" src="javascript/jquery.js"></script>
    <script type="text/javascript">
        var students = [
            { 'no': 'S001','name': '张三','address': '浙江' },{ 'no': 'S002','name': '李四','address': '江苏' },{ 'no': 'S003','name': '王五','address': '福建' },{ 'no': 'S004','name': '马六','address': '四川' }
        ];
        $(function () {
            InitStudents();
        });
        function InitStudents() {
            var html = '';
            $.each(students,function (i,item) {
                html += '<tr>';
                html += '<td>' + item.no + '</td>';
                html += '<td><span contenteditable="true" class="studentname">' + item.name + '</span></td>';
                html += '<td>' + item.address + '</td>';
                html += '</tr>';
            });
            $('#mainTbody').append(html);
        }
        function GetStudents() {
            var studentnames = '';
            $('#mainTbody span.studentname').each(function () {
                studentnames += '【' + $(this).text() + '】';
            });
            alert(studentnames);
        }
    </script>
</head>
<body>
    <div><input type="button" value="确定" onclick="GetStudents();" /></div>
    <div style="margin-top:10px;">
        <table>
            <thead>
                <tr>
                    <td>学号</td>
                    <td>姓名</td>
                    <td>地址</td>
                </tr>
            </thead>
            <tbody id="mainTbody"></tbody>
        </table>
    </div>
</body>
</html>

大佬总结

以上是大佬教程为你收集整理的html5 contenteditable 实现table可编辑全部内容,希望文章能够帮你解决html5 contenteditable 实现table可编辑所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: