HTML+CSS静态网页
js 交互、功能
=======================================
get Element By Id 通过id获取元素
获取 元素 用 id
--------------------------------
属性
特性 特点
blue.名字 blue
blue.性别 男
blue.身高 173
-----------------------------------
js 交互、功能
第一个js效果---鼠标提示框
鼠标移入到input上的时候,让div显示
鼠标移除input让div隐藏
div1显示: block
----------------------------------
事件
onclick
----------------------------------
div1.style.display='block'
. 的
div1的style的display
= 赋值
document.getElementById
兼容性问题
chrome
ff
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#div1{width:200px;height:100px; border:1px solid #999; background-color:#CCC;
display:none;}
</style>
</head>
<body>
<!--注释 -->
<input type="checkbox" onmouseover="document.getElementById('div1').style.display='block'"
onmouseout="document.getElementById('div1').style.display='none'"/>
<div id="div1" >
为了您的信息安全
</div>
</body>
</html>
=======================================
get Element By Id 通过id获取元素
获取 元素 用 id
--------------------------------
属性
特性 特点
blue.名字 blue
blue.性别 男
blue.身高 173
-----------------------------------
重用
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#div1{width:200px; height:200px; background:red;}
</style>
<script>
function toGreen(){
var odiv = document.getElementById('div1');
document.getElementById('div1').style.width='300px';
document.getElementById('div1').style.height='300px';
document.getElementById('div1').style.background='green';
}
function toRed(){
document.getElementById('div1').style.width='200px';
document.getElementById('div1').style.height='200px';
document.getElementById('div1').style.background='red';
}
</script>
</head>
<body>
<div id="div1" onmouseover="toGreen()" onmouseout="toRed()">
</div>
</body>
</html>