javascript - 如何使用 jquery 调整 html 表的行和列的大小?

标签 javascript jquery html css

我同时使用 colResizable(用于调整列)和 Resizable 函数(用于调整行)它在 mozilla firefox 中运行良好但在 chrome 中不起作用

对于专栏,我们使用以下链接 - http://quocity.com/colresizable/
对于行,我们使用以下 jquery 函数 - $("#tblResize2 tr").resizable();

注意:在上面的代码中,我们尝试使用 td(而不是 tr)来调整列的大小,但在最终影响后它不起作用。

$("#MatrixTable").colResizable({
                onResize: onSampleResized
            });

            $("#MatrixTable tr").resizable();
            $("#MatrixTable td").resizable();

整个函数

 var onSampleResized = function (e) {

  var columns = $(e.currentTarget).find("td");
            var rows = $(e.currentTarget).find("tr");
            var full_msg;
            var row_msg;

        `columns.each(function () { full_msg += $(this).attr('id') + "_" +` $(this).width() + "_" + $(this).height() + ";"; })
        rows.each(function () { row_msg += $(this).attr('id') + "_" + $(this).width() + "_" + $(this).height() + ";"; })
        document.getElementById("hf_data").value = full_msg
        document.getElementById("hf_rowdata").value = row_msg;

    };

提前致谢

最佳答案

我这里有一个工作示例: JSFiddle

我认为您的功能存在一些问题。有几个缺失的 ; chrome 可能不喜欢,请尝试以下操作。

完整的 Javascript:

$(function () {
        var onSampleResized = function (e) {
        var columns = $(e.currentTarget).find("th");
        var rows = $(e.currentTarget).find("tr");
        var full_msg = "";
        var row_msg = "";
        columns.each(function () {
            full_msg += $(this).attr('id') + ":" + $(this).width() + "x" + $(this).height() + ";\n";
        });
        rows.each(function () {
            row_msg += $(this).attr('id') + ":" + $(this).width() + "x" + $(this).height() + ";\n";
        });
        document.getElementById("hf_data").value = full_msg;
        document.getElementById("hf_rowdata").value = row_msg;
    };

    $("#MatrixTable").colResizable({
        onResize: onSampleResized
    });

    $("#MatrixTable tr").resizable();
    $("#MatrixTable td").resizable();



});

关于javascript - 如何使用 jquery 调整 html 表的行和列的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24685581/

相关文章:

javascript - 尝试从 WKWebView 中的 Javascript 获取信息(使用 KINWebBrowser)

javascript - Angular 2 中的 Fetch.js 提示 CORS 请求

javascript - 在 Javascript 中从数组数组解析 JSON

jquery - 防止 jQuery UI 对话框中的链接或按钮立即获得焦点?

html - IE8不渲染边框

javascript - 为什么我的 <marquee> 中的 link/span 标签在 Firefox 中出现在多行上?

javascript - 除非您单击标签中的图像,否则 IE onClick 不会选中复选框?

javascript - 是否可以使用 jQuery 来调用 Google map API?

android - 默认 Cordova index.html 正在编译

javascript - 在 Express JS 中设置 HTTPS