使用JavaScript更改表单元格宽度 [英] Using JavaScript to change table cells width

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

问题描述

我的表格的CSS宽度为150像素。

My table td width in CSS is 150px.

我想使用JavaScript将特定的td宽度更改为2px。

I am thinking of using JavaScript to change the particular td width to 2px.

如何做?

推荐答案

这样的东西>

Something like this (for the first one:

document.getElementsByTagName('td')[0].style.width = '2px';

或全部:

var tds = document.getElementsByTagName('td');

for (var i = 0; i < tds.length; i++)
    tds[i].style.width = '2px';

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

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