Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用jQuery width()更改Google图表表列宽不会';我不能改变宽度_Javascript_Jquery_Html_Css_Google Visualization - Fatal编程技术网

Javascript 使用jQuery width()更改Google图表表列宽不会';我不能改变宽度

Javascript 使用jQuery width()更改Google图表表列宽不会';我不能改变宽度,javascript,jquery,html,css,google-visualization,Javascript,Jquery,Html,Css,Google Visualization,我已经编写了一个函数来对齐多个Google图表表的列。jQuery实际上是用来更改列宽的,但我发现了一些奇怪的行为。我已经给出了下面的函数列表 match_table_column_sizes: function(table_wrapper, match_table_wrapper) { google.visualization.events.addListener(match_table_wrapper, 'ready', function() { var table_

我已经编写了一个函数来对齐多个Google图表表的列。jQuery实际上是用来更改列宽的,但我发现了一些奇怪的行为。我已经给出了下面的函数列表

match_table_column_sizes: function(table_wrapper, match_table_wrapper) {
    google.visualization.events.addListener(match_table_wrapper, 'ready', function() {
        var table_chart = table_wrapper.getChart();
        var match_table_chart = match_table_wrapper.getChart();

        var resize_function = function() {
            for (var i = 0; i < match_table_wrapper.getDataTable().getNumberOfColumns(); i++) {
                var match_cell = $('#' + match_table_wrapper.getContainerId() + ' td.google-visualization-table-th')[i];
                var cell = $('#' + table_wrapper.getContainerId() + ' td.google-visualization-table-th')[i];
                match_cell_width = $(match_cell).outerWidth();

                // ---- This is the weird bit --- //
                $(cell).width(match_cell_width);
                console.log(match_cell_width);
                console.log($(cell).width());
            }
        };
        resize_function();

        google.visualization.events.addListener(match_table_chart, 'sort', resize_function);
    });
},
如果有人有任何想法,我将不胜感激,因为我完全被难倒了


谢谢你的关注

尝试在控制台中记录变量,如cell。从表面上看,我认为你的选择器不起作用。a可能会有帮助。我也这么认为,但它确实提供了正确的元素!:(
$(cell).css('width', match_cell_width + 'px');
$(cell).css('width', '100px');