日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

html5 contenteditable 实现table可编辑(网页版EXCEL)

發布時間:2023/12/19 综合教程 27 生活家
生活随笔 收集整理的這篇文章主要介紹了 html5 contenteditable 实现table可编辑(网页版EXCEL) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一直想找一個免費的網頁版的EXCEL插件,以便于多人共同在線編輯,始終沒發現合適的。

其實自己實現類似功能也不難。參考:https://blog.csdn.net/chadcao/article/details/52014730

直接將以下代碼存在本地目錄中,如A.html,雙擊在瀏覽器中打開,即可對 姓名 字段進行編輯。

<!doctype html>
<html>
<head>
    <title>table contenteditable</title>
    <script type="text/javascript" src="http://libs.baidu.com/jquery/2.0.0/jquery.min.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>
        <table>
            <thead>
                <tr>
                    <td>學號</td>
                    <td>姓名</td>
                    <td>地址</td>
                </tr>
            </thead>
            <tbody id="mainTbody"></tbody>
        </table>
    </div>
</body>
</html>

總結

以上是生活随笔為你收集整理的html5 contenteditable 实现table可编辑(网页版EXCEL)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。