在JavaScript中更改表格列的宽度 [英] Changing width of tables columns in JavaScript

查看:98
本文介绍了在JavaScript中更改表格列的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用php和JavaScript的组合来更改多个表格单元格的宽度。当我将宽度指定为%值时,我创建了一个更改单元格宽度的循环,然后我决定将该值引用为适当的宽度但是如果我将它们作为px或者它们引用它则不起作用EM。有人可以帮助我。

我正在使用Firefox。循环也是在php中完成的,因为我无法在Firefox中使用它。如果有人可以在那里建议我哪里出错,那么它可能比过多地混合代码要好。如果从onclick上调用图像标记。

I''m trying to change the width of a number of table cells using a combination of php and JavaScript. I created a loop that changed the width of the cells when I specified the width as a % value, then I decided I''d rather reference the value as the proper width but it doesn''t work if I refrence them as px or em. Can someone help me.
I''m using Firefox. Also the loop is done in php becuase I couldn''t get it to work in Firefox. If someone could suggest where I''m going wrong there, it would proably be better than mixing code too much. If is being called from the onclick on an image tag.

展开 | 选择 | Wrap | 行号

推荐答案

使用JavaScript的。将PHP循环代码转换为JavaScript for循环。


我想你需要检查你是如何调用这个函数的。同时发布您的HTML代码(或至少部分内容)。
Use JavaScript. Convert the PHP loop code into a JavaScript for loop.

I think you''ll need to check how you''re calling this function. Also post your HTML code (or at least part of it).


我已经整理了循环。在错误控制中给我一个错误说
document.getElementById(" cola" + j)为空

然而它仍然会这样做,但仅限于当我的值为%时。

调用它的代码是:
I''ve sorted out the loop. Is gives me an error in the Error consol saying
document.getElementById("cola" + j) is null
However it still does it, but only when I have the values at %.
The code to call it is this:
展开 | 选择 | Wrap | 行号


你能否发帖表格HTML标记的前几行。
Could you post the first few lines of your table HTML markup.


这篇关于在JavaScript中更改表格列的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆