HTML中form表单隐藏input的两种方式



以下是两种常用的隐藏元素的方法:
第一种: 使用内联样式:在 input 元素上添加 style
="display: none;" 属性。 html <form action="/upload" method="post" enctype="multipart/form-data"> <input type="file" name="file" class="input" style="display: none;"> <input type="submit" value="上传" class="input button" style="display: none;"> </form>


第二种:
使用 CSS 类或 ID:在 CSS 文件中定义一个类或 ID,然后通过添加该类或 ID 到 input 元素上来隐藏元素。 html <style> .hidden { display: none; } </style> <form action="/upload" method="post" enctype="multipart/form-data"> <input type="file" name="file" class=".hidden"> <input type="submit" value="上传" class=".hidden"> </form>

 

posted @ 2023-10-10 15:06  胖豆芽  阅读(747)  评论(0编辑  收藏  举报