如何用js进行表格排序和编辑啊,主要是如何进行编辑,具体代码给我吧!!小弟不胜感激。在线等待....

解决方案 »

  1.   

    以前不懂时到网上搜罗一大圈后写的
        <script type="text/javascript">        var input = document.createElement("input");
            input.type = "text";        var cell;
            function editCell(e) {
                if (e == null) {
                    cell = window.event.srcElement;
                }
                else {
                    cell = e.target;
                }
                if (cell.tagName == "TD") {                input.value = cell.innerHTML;                input.onblur = setValue;
                    cell.innerHTML = "";                cell.appendChild(input);
                    input.focus();
                }
            }        function setValue() {
                cell.innerHTML = input.value;
            }
            function initEvent() {
                document.getElementById("editTable").ondblclick = editCell;
            }
        </script></head>
    <body onload="initEvent()">
        <table id="editTable" border="1">
            <tr>
                <td>哈哈</td>
                <td>呵呵</td>
                <td>呜呜</td>
            </tr>
        </table>
    </body>
      

  2.   

    可以使用jquery tablesorter 插件,