可以用css或者js判断table的width,然后修改它的table的宽吗?

kingkongc 2017-11-01 09:59:52

<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center">
<tr>
<td height="26">
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
我是文字内容1
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center">
<tr>
<td>
我是文字内容2
</td>
</tr>
</table>

页面中有多个table,而且没有id,没有class,他们都有width=宽百分几,现在想用css或者js判断table中width=98%的,就把它改成100%,页面中可能有多个table=98%;其他table=50%或者table=90%这些就不动它。
能用css那最好,js估计要用onload所以怕兼容问题,jquery不能用。额,不好意思,这个要求太折腾人了,我也是深受其害啊。
...全文
252 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
丰云 2017-11-02
  • 打赏
  • 举报
回复
引用 楼主 dedecmsdiy 的回复:

<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center">
	<tr>
		<td height="26">
			<table width="98%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td align="center">
						我是文字内容1
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table width="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center">
	<tr>
		<td>
			我是文字内容2
		</td>
	</tr>
</table>
页面中有多个table,而且没有id,没有class,他们都有width=宽百分几,现在想用css或者js判断table中width=98%的,就把它改成100%,页面中可能有多个table=98%;其他table=50%或者table=90%这些就不动它。 能用css那最好,js估计要用onload所以怕兼容问题,jquery不能用。额,不好意思,这个要求太折腾人了,我也是深受其害啊。
你这就难了,限制太多 用js吧,找到所有table然后遍历
  • 打赏
  • 举报
回复
<style> table[width="98%"]{width:100%} </style> <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center"> <tr> <td height="26"> <table width="98%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"> 我是文字内容1 </td> </tr> </table> </td> </tr> </table> <table width="50%" border="0" cellpadding="0" cellspacing="1" bgcolor="#ccd9b9" align="center"> <tr> <td> 我是文字内容2 </td> </tr> </table>

Web开发学习资料推荐
jquery attr prop 区别
jqGrid事件

87,993

社区成员

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

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