有办法得到一个对象的属性列表吗?比如
中width,height...

alula 2001-12-06 09:22:23
这些属性在对象中是怎么保存的,有办法判断这个<tr>是否具有 width 属性呢?
...
...全文
93 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
karma 2001-12-07
  • 打赏
  • 举报
回复
<table id="tbl">
<tr><td>hello</td><td>world</td></tr>
<tr width='95%' height='20'><td>hello</td><td>world</td></tr>
<tr width='95%' height='20'><td>hello</td><td>world</td></tr>
</table>
<input type="button" value="show Att" onclick="showAtt()">

<script language="javascript">
function showAtt()
{
var row = document.all("tbl").rows[0]; //second row
var width = row.getAttribute("width");
var height = row.getAttribute("height");

if (width)
alert("we have a width attribute, its value:" + width);
else
alert("we don't have a width attribute");

if (height)
alert("we have a height attribute, its value::" + height);
else
alert("we don't have a height attribute");
}
</script>
y1g1y1 2001-12-07
  • 打赏
  • 举报
回复
查 MSDN 啊!
feijunjun 2001-12-07
  • 打赏
  • 举报
回复
<table>
<tr id=abc width=80 height=40 tt=200>
<td>tr中的tt是一个自定义属性</td>
</tr>
</table>
<script>
for(var e in abc){
document.write(e + "<BR>")
// 要直接访问属性,你就用 alert(abc.width); alert(abc.tt); alert(abc.height)
}
</script>
alula 2001-12-07
  • 打赏
  • 举报
回复
thanx
alula 2001-12-07
  • 打赏
  • 举报
回复
thanx!
alula 2001-12-07
  • 打赏
  • 举报
回复
多谢多谢!
多谢feijunjun(军仔):
for(var e in abc) { //。。。
加分加分
width="100%" border="0" cellspacing="0" cellpadding="0"><table width="100%" border="0" cellspacing="0" cellpadding="0"> 这是表格的开始部分代码,表格的宽为100%,就是与浏览器等宽的,border表示表格的线宽为0即不显示表格线,cellspacing表示表格内数据与表格间隔为0,cellpadding表示单元格与单元格间隔为0,一般这个代码用于做网页的布局的。 ...
width="500px" height="150px"> <tr align="center"> tr> <tr align="center">
第一行第一列 第一行第二列 第二行第一列 第二
标签的widthheight属性无法设置....亲测有效 解决table标签下的和属性宽和高设置无效 在写table表格框的时候,会遇到自己的属性设置了width: :属性height:;属性,可预览的时候不会有任何的变化,你的表格还是一团没有任何的可看性。废话不多说,我们一起来看看吧 table{ table-layout: fixed; } 只要在table标签里设置table-layout属性值为fixed,然后在设置widt...

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧