js 知识总结

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("提示框")
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值