tbody的有趣问题

tbody标签很有意思,即使你并不去添加它,浏览器也会自动帮你补上。

==============================

<style type="text/css">
tbody{color:red}
</style>
<table>
<tr id="a"><td>123</td></tr>
</table>
<script type="text/javascript">
alert(document.getElementById("a").parentNode.tagName);
</script>

==============================

没错,弹窗弹的是tbody,而123的颜色是红色。IE6、7、8,firefox和chrome都是如此。

转载于:https://www.cnblogs.com/cly84920/archive/2010/05/27/4426776.html

<!DOCTYPE html><html><head> <title>管理员页面</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; } nav { background-color: #333; color: #fff; display: flex; justify-content: space-between; padding: 10px; } nav a { color: #fff; padding: 10px; text-decoration: none; } nav a:hover { background-color: #fff; color: #333; } section { padding: 20px; } form { display: flex; flex-direction: column; margin-bottom: 20px; } label { margin-bottom: 10px; } input[type="text"] { padding: 5px; border: 1px solid #ccc; border-radius: 3px; margin-bottom: 10px; } input[type="submit"] { background-color: #333; color: #fff; padding: 5px; border: none; border-radius: 3px; cursor: pointer; } table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid #ccc; padding: 10px; text-align: left; } th { background-color: #333; color: #fff; } </style></head><body> <nav> <a href="#add-user">添加用户</a> <a href="#delete-user">删除用户</a> </nav> <section id="add-user"> <h1>添加用户</h1> <form> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> <label for="password">密码:</label> <input type="text" id="password" name="password" required> <input type="submit" value="添加用户"> </form> </section> <section id="delete-user"> <h1>删除用户</h1> <table> <thead> <tr> <th>用户名</th> <th>操作</th> </tr> </thead> <tbody> <tr> <td>User1</td> <td><button>删除</button></td> </tr> <tr> <td>User2</td> <td><button>删除</button></td> </tr> <tr> <td>User3</td> <td><button>删除</button></td> </tr> </tbody> </table> </section></body></html>
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值