第一課鼠標(biāo)提示框
代碼
<html>
<head>
<metacharset="UTF-8">
<title>ghjtitle>
head>
<style>
#div1{
height:60px;
width:150px;
background:pink;
display:none;
}
style>
<body>
<inputtype="checkbox"onmouseover="document.getElementById('div1').style.display='block';"onmouseout="document.getElementById('div1').style.display='none';"/>
<divid="div1">請注意不要在公共電腦保留私人信息div>
body>
html>
1帮掉、樣式猪贪,Div的display
2涯穷、事件即動作Onmouseover、onmouseout
3格粪、doucument.getelemengtbyid(divid)處理兼容問題
4、屬性即特點style.屬性(身高、體重等)
5改淑、函數(shù)function名字(){
}
6亮蛔、重用痴施,使布局更加清晰、效率更高
7、函數(shù)的定義和調(diào)用缺一不可
8辣吃、任何標(biāo)簽都可以加標(biāo)簽link
9动遭、Html中怎么寫,js就怎么寫
10神得、作業(yè)設(shè)置文字完成
<html>
<head>
<metacharset="UTF-8">
<title>作業(yè)2title>
<style>
#div1{
height:100px;
width:100px;
background:pink;
display:none;
}
style>
<script>
functionshowhide(){
varOdiv=document.getElementById('div1');
if(Odiv.style.display=='none'){
Odiv.style.display='block';
}
else{
Odiv.style.display='none';
} ???????}
script>
head>
<body>
<inputtype="button"value="顯示/隱藏"onclick="showhide()"/>
<divid="div1">猜猜我是誰div>
body>
html>
11厘惦、a鏈接鏈接 ?#可以替代javascript:alert(a);告訴瀏覽器用js
12循头、Class不可以用绵估,只能classname
13、參數(shù)卡骂、變量不需要加引號
<html>
<head>
<metacharset="UTF-8">
<title>Titletitle>
<style>
#div1{
height:200px;
width:70px;
background:lightpink;
}
style>
head>
<body>
<inputid="but1"type="button"value="全選"/>
<inputid="but2"type="button"value="返選"/>
<inputid="but3"type="button"value="不選"/>
<divid="div1">
<inputtype="checkbox"/>勾選1
<inputtype="checkbox"/>勾選2
<inputtype="checkbox"/>勾選2
<inputtype="checkbox"/>勾選3
<inputtype="checkbox"/>勾選4
<inputtype="checkbox"/>勾選5
<inputtype="checkbox"/>勾選6
div>
<script>
window.onload=function()
{
varOdiv1=document.getElementById('div1');
varbt1=document.getElementById('but1');
varbt2=document.getElementById('but2');
varbt3=document.getElementById('but3');
varoche=Odiv1.getElementsByTagName('input');
bt1.onclick=function()
{
for(vari=0;ilength;i++)
{
oche[i].checked=true;
}
}
bt3.onclick=function()
{
for(vari=0;ilength;i++)
{
oche[i].checked=false;
}
}
bt2.onclick=function()
{
for(vari=0;ilength;i++)
{
if(oche[i].checked==true)
oche[i].checked=false;
else{
oche[i].checked=true;
}
}
}
}
script>
body>
html>