<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script type="text/javascript">
// function clickD(obj){
// alert(obj.innerHTML);
// }
// function mouseD(obj){
// obj.style.color="#f00"; //设置这个对象的颜色,在js中设置样式均通过xx.stlye.样式名称
// obj.style.fontSize="18px"; //当使用代码来设置样式时,在css中通过“-”来表示的,都是有驼峰标识,font-size-----fontSize
// }
// function outD(obj){
// obj.style.color="#000";
// obj.style.fontSize="16px";
// }
with(document){ //此时花括号中所有代码都是基于document作为根对象,当使用write(xx)就等于document.write
write("ddd<br/>");
write("eee<br/>");
alert("陈"); //使用alert也是允许的
}
//document.write("aaa<br/>");
//document.write("bbb<br/>");
//document.write("ccc<br/>");
</script>
</head>
<body>
<div οnclick="clickD(this)" style="cursor:pointer">点一下试试</div>
<div οnmοuseοver="mouseD(this)" οnmοuseοut="outD(this)">鼠标移过来试试</div>
</body>
</html>
Javascript — 简单事件处理
最新推荐文章于 2024-07-25 01:51:24 发布