两个Table,我想在脚本中使tb2的样式和tb1的一样,包括cellSpacing=1 border=0 还有 style等等

cqxhhe 2003-04-27 02:03:23
两个Table

<TABLE id=tb1 style="..." cellSpacing=1 cellPadding=0 width="100%" align=center border=0>....</table>

<TABLE id=tb2>....</table>

我想在脚本中使tb2的样式和tb1的一样,包括cellSpacing=1 cellPadding=0 width="100%" align=center border=0 还有 style等等
因该怎么写?
...全文
144 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
cqxhhe 2003-04-27
  • 打赏
  • 举报
回复
使用mergeAttributes不会改变id,但是会拷贝event

好 要的就是全部!
fason 2003-04-27
  • 打赏
  • 举报
回复
<table id=tb1 style=color:red cellSpacing=1 cellPadding=0 width="100%" align=center border=5>
<tr>
<td width="100%">1</td>
</tr>
<tr>
<td width="100%">2</td>
</tr>
</table>

<table id=tb2>
<tr>
<td width="100%"> 1</td>
</tr>
<tr>
<td width="100%">2 </td>
</tr>
</table>
<script>
tb2.mergeAttributes(tb1)
</script>
hyee 2003-04-27
  • 打赏
  • 举报
回复
使用mergeAttributes不会改变id,但是会拷贝event
hyee 2003-04-27
  • 打赏
  • 举报
回复
var sHTML=<new_table_id>.innerHTML
<new_table_id>.mergeAttributes(<old_table_id>)
<new_table_id>.innerHTML=sHTML
cqxhhe 2003-04-27
  • 打赏
  • 举报
回复
tb1.outerHTML.substring(0,tb1.outerHTML.search('>')+1));
这样能简单的实现取出table标签内的内容
但ID却会重复
怎么板呢?
cqxhhe 2003-04-27
  • 打赏
  • 举报
回复
up

怎么样,能做到吗?
cqxhhe 2003-04-27
  • 打赏
  • 举报
回复
包括
style="..." cellSpacing=1 cellPadding=0 width="100%" align=center border=0 bgcolor=red

cqxhhe 2003-04-27
  • 打赏
  • 举报
回复
阿 这个有点太厉害了
全都换了,包括内容

我想只换样式
纯粹是这里面的内容
<TABLE id=tb1 style="..." cellSpacing=1 cellPadding=0 width="100%" align=center border=0 bgcolor=red>
fason 2003-04-27
  • 打赏
  • 举报
回复
<table id=tb1 style="color:red" cellSpacing=1 cellPadding=0 width="100%" align=center border=0>
<tr>
<td width="100%">1</td>
</tr>
<tr>
<td width="100%">2</td>
</tr>
</table>

<table id=tb2>
<tr>
<td width="100%"> 1</td>
</tr>
<tr>
<td width="100%">2 </td>
</tr>
</table>
<script>o=tb1.cloneNode(true);o.id='tb2';tb2.replaceNode(o)</script>
孟子E章 2003-04-27
  • 打赏
  • 举报
回复
<TABLE id=tb1 style="..." cellSpacing=1 cellPadding=0 width="100%" align=center border=0 bgcolor=red><tr><td>....</td></tr></table>

<TABLE id=tb2>....</table>

<input type=button onclick="o=document.all.tb1.cloneNode(true);o.id='tb2';document.all.tb2.replaceNode(o);alert(document.all.tb2.outerHTML)" value="do it">
孟子E章 2003-04-27
  • 打赏
  • 举报
回复
<TABLE id=tb1 style="..." cellSpacing=1 cellPadding=0 width="100%" align=center border=0 bgcolor=red><tr><td>....</td></tr></table>

<TABLE id=tb2>....</table>

<input type=button onclick="o=document.all.tb1.cloneNode(true);o.id='tb2';document.all.tb2.replaceNode(o)">
cqxhhe 2003-04-27
  • 打赏
  • 举报
回复
还有Class等等

如果用css
cellSpacing=1 cellPadding=0 width="100%" align=center border=0
怎么描述?

87,987

社区成员

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

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