docunment对象

找元素:

 document.getElementById()       根据ID找

 document.getElementsByClassName()     根据class找,返回数组

 document.getElementsByName()     根据name找,返回数组

 document.getElementsByTagName()      根据标签名找,返回数组

操作内容:

普通元素:innerText获取内容文本                innerHTML获取内容代码

表单元素:value

操作属性:

setAttribute(属性名,属性值)设置属性

removeAttribute(属性名)移除属性

getAttribute(属性名)获取属性

cheched,cheched

操作样式:

a.style.width获取样式只能获取内联的

onmosemove鼠标移动  onmouseout 鼠标离开   onmouseover鼠标移上  

onkey  键盘按键触发元素

表单元素  onblur  test 当失去焦点是触发事件

表单元素   onfocus   获得焦点时触发

表单元素onchange   内容变化触发

window.history对象:

历史记录,通过历史记录可以操作页面前进或者后退

window.history.back();后退

window.history.forward();前进

window.history.go(n); n是正数代表前进n个页面,n是负数代表后退n个页面。*

location地址栏:

var s = window.location.href;获取当前页面的地址

window.location.href="http://www.baidu.com";修改页面地址,会跳转页面 *******

window.location.hostname: 主机名,域名,网站名,可用变量接收

window.location.pathname: 路径名,可用变量接收

 window.status对象:

status状态栏,可以给状态栏添加要显示的文字

window.status="要在状态栏显示的内容";设置状态栏文字

 

posted @ 2017-12-06 09:12  palpitate  阅读(614)  评论(0编辑  收藏  举报