Js 操作屬性
document .getElementByid("div1");根據(jù)ID來(lái)獲群笫摇;
document .之后getElementByid("div1") .title = "你真美" ;
整個(gè)文檔加載完之后執(zhí)行的一個(gè)匿名函數(shù)唠摹;
function 匿名函數(shù);
window .onload = function() {} 寫在《script》標(biāo)簽里面;
通過id來(lái)查找文檔中的唯一id
document getElementByid ("link") .href = "www.baifu.com",(跳轉(zhuǎn)到網(wǎng)頁(yè))
還可以 例如 : var oA = document .getElentByid("link");
oA .href = "www.baidu.com"
oA .title = "去到百度網(wǎng)"晴竞;
還可以讀出來(lái) : alert (oA.id) alert (oA.title);
對(duì)象 . 方法 ; 對(duì)象 . 屬性 ;
js換膚
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="css/1.css" id="p2">
<script type="text/javascript">
window.onload=function () {
var b1 =document.getElementById('p');
var b2 =document.getElementById('p1');
b1.onclick = s1;
b2.onclick = s2;
}
function s1(){
var olick=document.getElementById("p2");
olick.href="css/1.css";
}
function s2(){
var olick=document.getElementById("p2");
olick.href="css/2.css";
}
</script>
</head>
<body>
<input type="button" name="" value="皮膚01" id="p" />
<input type="button" name="" value="皮膚02" id="p1" />
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
作業(yè)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
ul{
margin: 0;
padding:0;
}
.p {
width: 960px;
height: 40px;
background-color:#55a8ea;
margin: 50px auto;
}
.p ul li{
list-style-type:none;
width: 100px;
float: left;
text-align: center;
}
.p ul li a{
text-decoration:none;
font-size: 14px;
color: white;
line-height: 42px;
}
.p ul li:hover{
background-color:#00619f;
}
.p1{
position: relative;
top: -10px;
left: -267px;
}
</style>
</head>
<body>
<div class="p">
<ul>
<li><a href="#">首頁(yè)</a></li>
<li><a href="#">網(wǎng)站建設(shè)</a></li>
<li><a href="#">程序開發(fā)</a></li>
<li><a href="#">網(wǎng)絡(luò)營(yíng)銷</a></li>
<img src="new.png" class="p1">
<li><a href="#">企業(yè)VI</a></li>
<li><a href="#">案列展示</a></li>
<li><a href="#">聯(lián)系我們</a></li>
</ul>
</div>
</body>
</html>
image.png