您的位置:首页 > Web前端 > JavaScript

js 知识总结

2013-11-11 18:39 281 查看
JS 总结

事件

1 语法: onclick = js ("函数")("语句")

2 事件句柄: onclick onfcus ...

3 鼠标/键盘属性: altKey (event.altKey==1 表示alt 这个建被按)event.clientX(鼠标横坐标)

DOM 处理



1 访问节点

getElementById() getElementsByTagName() getElementsByClassName("");

2 操作html

改变html内容:document.getElementById(id).innerHtml = new Html

改变html属性:(获取节点).attribute = new value

(document.getElementById("image").src = "a.jpg":)

3 操作css

改变css样式:(获取节点).style.property = new style

document.getElementById("p2").style.color = "bule";

显示影藏:(获取节点).visibility = 'hidden' (visible)

4 操作节点

增加节点 步骤

1 创建<p>

var para = doucument.createElemnt("p");

2 创建节点内容

var node = doucument.createTextNode("内容");

3 将内容追加到节点

para.appendChild(node);

4 将新元素放入指定的位置

var elemnet = document.getElementById("div1");

element.appenChild(para);

删除节点

var parent = document.getElementById("div1");

var child = document.getElemntById("p1");

parent.removeChild(child);

Window(BOM流浪器对象模型)

1 window :window.innerHeight(Width)浏览器的高和宽

2 screen:screen.availWidth(Height) 可用屏幕宽高

3 Location: window.location("src") 刷新

4 History: window.history.back() (forward) 无刷新

5 PopuAlert: alert("警告框"); confirm("确定框") ; prompt("提示框")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: