4.下拉列表
下拉列表<selcted>
标签是整体,里面的每一项是<option>
,一般用于选择地区。
optgroup可以进行分组,里面的lable值是显示的分组的名字。
<select name="menu" id="">
<optgroup label="省份选择">
<option value="">----请选择----</option>
<option value="1">广东省</option>
<option value="2">江西省</option>
<option value="3">江苏省</option>
</optgroup>
</select>
<!-- <optgroup>属性可以把下拉菜单中的内容分组
然后optgroup中的lable属性可以设置这个租的名称 -->
5.按钮<button>
在 <button>
元素内部,您可以放置内容,比如文本或图像。这是该元素与使用 <input>
元素创建的
按钮之间的不同之处。
提示:请始终为 <button>
元素规定 type 属性。不同的浏览器对 <button>
元素的 type 属性使用不同
的默认值。
type属性:可以设置三个值 submit/reset/button与input元素设置的按钮含义一致。默认为submit属性。
6.表单元素的属性
属性 | 值 | 描述 |
---|---|---|
type | 上述值 | type 属性规定要显示的 <input> 元素的类型。 |
value | text | 指定 <input> 元素 value 的值。 |
src | URL | src 属性规定显示为提交按钮的图像的 URL。 (只针对 type=“image”) |
size | number | size 属性规定以字符数计的 <input> 元素的可见宽度。 |
readonly | readonly | readonly 属性规定输入字段是只读的。 |
name | text | name 属性规定 <input> 元素的名称。 |
maxlength | number | 属性规定 <input> 元素中允许的最大字符数。 |
disabled | disabled | disabled 属性规定应该禁用的 <input> 元素。 |
checked | checked | checked 属性规定在页面加载时应该被预先选定的 元素。 (只针对 type=“checkbox” 或者type=“radio”) |
accept | audio/* video/* image/* MIME_type | 规定通过文件上传来提交的文件的类型。 (只针对type=“file”) |
selected | selected | 下拉框的默认选中 |
所有表单元素中,每个元素都需要写name=‘值’ ,这样后端才可以看到信息内容代表什么。例如:
<fieldset>
<legend>填写内容啦快</legend>
<input type="text" placeholder="手机/邮箱/用户名" class="one" name="username"><br>
<input type="password" placeholder="密码" class="one" name="password" ><br>
<input type="checkbox" class="two" checked >下次自动登录<br>
<input type="submit" value="登录" class="three"><br>
</fieldset>
<label for="women"><input type="radio"name='sex' value="1" id="women">女</label>
<label><input type="radio" name="sex" value="2">男</label><br>
爱好:
<input type="checkbox" name="hobby" value="1" id="basketball"><label for="basketball">打篮球</label>
<input type="checkbox" name="hobby" value="2" id="football"><label for="football">踢足球</label>
<input type="checkbox" name="hobby" value="3" id="pingpang"><label for="pingpang">打乒乓球</label>
所有写name 的元素,传递数据时很清晰。
意思就是对应标签的 name的属性值等于输入的的内容