a标签
属性
-
href超链接 -
target指定在哪个窗口打开链接 -
download下载页面,很多浏览器不支持 -
rel=noppener
target的取值
target="_self"默认,在当前页面打开链接target="_blank"在空白页面打开链接target="_top"在顶层页面打开链接target="_parent"在父类页面打开链接- 程序员命名 window的name
iframe的name
href的取值
-
网址
- google.com
- google.com
- //google.com 自动选择https或http
-
路径
- /a/b/c以及a/b/c
- index.html以及./index
-
伪协议
JavaScript:代码;执行javascript代码JavaScript:;什么的不做,也不会刷新页面
-
id
href=#xxxid,跳转到指定标签
-
mailto: 邮箱,自动填写邮箱
-
tel: 手机号,自动填入手机号
table标签
相关标签
<thead></thead>表格头部<tbody></tbody>表格身体<tfoot></tfoot>表格脚部<tr></tr>表格里面的一行<th></th>表头<td></td>表格里面的数据
相关样式
table-layout:auto根据内容自动设置宽度table-layout:fixed等宽border-spacing: 0px;控制间隙的距离border-collapse: collapse表格间隙合并
img标签
作用
发出GET请求,展示一张图片
属性
src图片地址alt图片加载失败,显示alt内容height高度width宽度
只写高度或宽度,图片会自适应,2个都写,图片强制变形
事件
监听图片是否加载成功
onload加载成功onerror加载失败
<img id="xxx" src="1.jpg" alt="美照">
<script>
xxx.onload = function(){
console.log('图片加载成功')
}
xxx.onerror = function(){
console.log('图片加载失败')
xxx.src = "404.jpg"
}
</script>
响应式
max-width: 100% 使图片变成响应式,根据设备大小自行更改,不会固定大小
form标签
作用
发get或post请求,然后刷新页面
属性
action控制请求页面地址method控制发送GET还是POST请求autocomplete="on"自动给出建议target提交到哪个页面target="_self"当前页面target="_blank"空白页面target="_top"顶层页面target="_parent"父类页面
input标签: 输入框
type属性常用取值
<input type="text">普通文本<input type="password">密码<input type="button">按钮<input type="color">选择颜色- 单选框,name需一样
<input name="xxx" type="radio">男
<input name="xxx" type="radio">女
- 多选框,name一样为一组
<input name="yyy" type="checkbox">唱
<input name="yyy" type="checkbox">跳
<input name="yyy" type="checkbox">rap
<input name="yyy" type="checkbox">篮球
<input type="file">文件<input type="file" multiple>文件多选<input type="hidden">隐藏,看不见的
事件
onchange用户改变了内容onfocus鼠标聚焦onblur鼠标失去聚焦required必填,否则无法提交
多行文本
<textarea></textarea> 多行文本输入框
<textarea style="resize: none"></textarea> 不允许更改大小
下拉框
<select>
<option value="">请选择</option>
<option value="1">星期一</option>
<option value="2">星期二</option>
<option value="3">星期三</option>
</select>
注意事项
-
一般不监听input的click事件
-
form里面的input要有name
-
form表单必须要有一个
type="submit"
如果不写,默认为submit
如果type="button"就不能提交表单 -
input和button提交区别
<input type="submit" value="提交"> <button type="submit">提交</button>两者区别:button里面还可以添加标签,input不能