Html中 <tr> 标签的隐藏与显示

本文介绍了一种使用JavaScript和HTML结合的方式实现对表格行(TR标签)的动态显示与隐藏的方法。通过设置style属性中的display参数为'block'或'none'来达到效果。此外,还提供了一个简单的函数changeTR,用于根据外部条件改变TR标签的可见性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

TR标签的隐藏与显示:block(显示)和none(隐藏) 

 <tr  style="display:none"> 

<tr id="sample"
            style="display: <s:if test="sample == 1">block</s:if><s:else>none</s:else>">
            <td>
                sample
            </td>
</tr>
<script type="text/javascript">
function changeTR(selectedValue)
{
    var tr1 = document.getElementById("sample");

    if (selectedValue == 0)
    {
        tr1.style.display = 'block';
    }
    else
    {
        tr1.style.display = 'none';
    }
}
</script>

 

<!DOCTYPE html> <html lang='en'> <head> <meta charset='UTF-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <title>EDA-Robot</title> <style> body { margin: 0; padding: 0; font-family: Arial, sans-serif; } .container { max-width: 800px; margin: 0 auto; padding: 20px; text-align: center; } h1 { text-align: center; } .button { display: inline-block; height: 30px; width: 300px; margin-top: 20px; padding: 10px 20px; background-color: deepskyblue; color: #fff; border: none; border-radius: 20px; /* 添加圆角 */ text-decoration: none; line-height: 2; /* 通过调整line-height的值来调整文字的垂直位置 */ text-align: center; /* 文字居中 */ box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); /* 添加立体感 */ transition: all 0.3s ease; /* 添加过渡效果 */ } .button:hover { background-color: skyblue; /* 鼠标悬停时的背景颜色 */ transform: translateY(2px); /* 点击效果 */ box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3); /* 添加更多立体感 */ } .search-box { margin-top: 20px; display: inline-block; height: 30px; width: 300px; padding: 5px 10px; background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 20px; text-align: center; /* 文字居中 */ } .hidden { display: none; /* 初始隐藏 */ } </style> </head> <body> <form action='/connect' method='POST'> <div class='container'> <h1>EDA-Robot设备配置页</h1> <p>本项目基于ESP8266主控开发</p> <input type='text' name='ssid' placeholder='输入WIFI212名称' class='search-box'> <input type='password' name='pass' placeholder='输入WIFI密码' class='search-box'> <input type='uid' name='uid' placeholder='输入bilibili用户ID' class='search-box'> <input type='api' name='api' placeholder='输入心知天气API密钥' class='search-box'> <input type='city' name='city' placeholder='输入城市拼音小写' class='search-box'> <input type='submit' style="height: 50px;width: 320px" class='button' value="保存"> <a href="https://lceda.cn/"> <table class="container button" style="height: 200px"> <tr> <th>设备名称:</th> <td>EDA-Robot</td> </tr> <tr> <th>内存大小:</th> <td>4MB</td> </tr> <tr> <th>控制台版本:</th> <td>V1.0</td> </tr> <tr> <th>作者:</th> <td> 臣除君</td> </tr> </table> </a> </div> </form> </body> </html>为什么这里的 <tr> <th>设备名称:</th> <td>EDA-Robot</td> </tr>是横向排版的?
最新发布
08-12
``` <form action="xxx.jsp" method="GET" name="性别;生日;所在地区;婚姻状况;学历;喜欢的类型;自我介绍;"> <table width="500"> <style> body{ display:grid; place-content: center; height: 100vh; margin: 0%; font-family: '黑体'; font-size: 100px; } </style> <tr> <td><b>性别</b></td> <td> <input type="radio" id="man" name="sex"/> <label for="man"><img src="images/man.jpg"> 男 </label> <input type="radio" id="women" name="sex"/> <label for="women"><img src="images/women.jpg"> 女 </label> </td> </tr> <tr> <td><b>生日</b></td> <td> <select name="year"> <option selected="selected">--请选择年--</option> <option>1990</option> <option>2000</option> <option>2010</option> </select> <select name="month"> <option selected="selected">--请选择月--</option> <option>1</option> <option>2</option> <option>3</option> </select> <select name="day"> <option selected="selected">--请选择日--</option> <option>11</option> <option>12</option> <option>13</option> </select> </td> </tr> <tr> <td><b>所在地区</b></td> <td> <input type="text" value="安徽" name="area"> </td> </tr> <tr> <td><b>婚姻状况</b></td> <td> <input type="radio" name="marital_status" id="spinsterhood"> <label for="spinsterhood"> 未婚 </label> <input type="radio" name="marital_status" id="married"> <label for="married"> 已婚 </label> <input type="radio" name="marital_status" id="divorce"> <label for="divorce"> 离婚 </label> <input type="radio" name="marital_status" id="secret"> <label for="secret">保密</label> </td> </tr> <tr> <td><b>学历</b></td> <td><input type="text" name="edu_bg"></td> </tr> <tr> <td><b>喜欢的类型</b></td> <td> <input type="checkbox" name="like_type" id="wumei"> <label for="wumei"> 妩媚的 </label> <input type="checkbox" name="like_type" id="keai"> <label for="keai"> 可爱的 </label> <input type="checkbox" name="like_type" id="xiaoxianrou"> <label for="xiaoxianrou"> 小鲜肉 </label> <input type="checkbox" name="like_type" id="laolarou"> <label for="laolarou"> 老腊肉 </label> <input type="checkbox" name="like_type" id="douxihuan"> <label for="douxihuan"> 都喜欢 </label> </td> </tr> <tr> <td><b>自我介绍</b></td> <td> <textarea cols="30" rows="10" name="self_introduction"></textarea> </td> </tr> <tr> <td> <input type="submit" value=" 免费注册 "> </td> </tr> </table> </form>```帮我修改一下
04-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值