标签:
本章主干知识点:
1、<a onclick="f1()"/> document.getElementById("btn1").onclick=function(){}
2、setInterval、setTimeout
3、事件冒泡以及如何阻止事件冒泡;
4、如何动态创建元素和动态添加元素;
5、innerText和innerHTML区别
6、案例:动态加载数据到table中;
-------------------------------------------------------------------------------
操作DOM的意义
document.getElementById("btnShake").onclick = function () {
var divBody = document.getElementById("divBody");
divBody.style.position = "absolute";
setInterval(function () {
divBody.style.left = (Math.random() * 100) + "px";
divBody.style.top = (Math.random() * 200) + "px";}, 20);};
var btnClickMe = document.getElementById("btnClickMe");btnClickMe.onclick = function () {alert("老公,你好厉害!");};btnClickMe.onmouseenter = function () {
var left = window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
var top = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
this.style.left = (left + 30)+"px";this.style.top = (top - 30) + "px";};
screen对象,获取屏幕的信息:
alert("分辨率:" + screen.width + "*" + screen.height);
if (screen.width < 1024 || screen.height < 768) {
alert("分辨率太低!");
}
<table border="1" id="tb">
<tr><td> 乐乐:</td><td>我又胖了!</td></tr>
</table>
昵称:<input type="text" id="txt" /><br />
<textarea id="textContent" rows="10" cols="15"></textarea><br />
<input type="button" value="评论" id="btn1" />
</table>
标签:
原文地址:http://www.cnblogs.com/wjs5943283/p/5247858.html