JS_事件、行为、结构分离
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS_事件、行为、结构分离</title>
</head>
<style type="text/css">
ul,li,div {
margin: 0;
padding: 0;
list-style: none;
}
div{
width: 200px;
height: 200px;
border: 2px dashed lawngreen;
}
</style>
<body>
<div onclick="con();">
<p>
<ul>
<li>行为、结构、事件分离</li>
</ul>
</p>
</div>
<p>把事件,CSS,和结构都分开写就好了,显得页面结构清晰</p>
</body>
<script type="text/javascript">
document.getElementsByTagName('div')[0].onmousemove=function(){
this.style.border='1px solid red';
}
document.getElementsByTagName('div')[0].onmouseleave=function(){
this.style.border='';
}
</script>
</html>
Dcr163的博客
http://dcr163.cn/57.html(转载时请注明本文出处及文章链接)