標籤:style java color os strong io cti html
<!doctype html><html lang="en"> <head> <meta charset="UTF-8"> <title>JS練習第一課</title> </head> <link id="bg" rel="stylesheet" type="text/css" href=""> /這裡是給了引入的樣式表一個ID,空值它引入的樣式地址/ <style type="text/css"> div{ color:#FFF; font-size:16px; font-family:microsoft yahei; font-weight:700; line-height:50px; text-align:center; border:1px solid blue; display:none; //div預設為隱藏 } </style> <script type="text/javascript"> function bloc() //滑鼠移至上方執行此函數,onmouseover { var aDiv=document.getElementById(‘div1‘); /擷取div1這個ID,並給他取個名字為aDiv/ var aBg=document.getElementById("bg"); /擷取bg這個ID,並給他取個名字為aBg/ aDiv.style.display="block" /讓它的display顯示/ aDiv.style.background="pink" /讓它的背景變為粉色/ aDiv.style.width="180px" /讓它的寬變為180像素/ aDiv.style.height="50px" /讓它的高變為50像素/ aBg.href="a.css" } function non() //滑鼠移除執行此函數,onmouseout { var aDiv=document.getElementById(‘div1‘); /擷取div1這個ID,並給他取個名字為aDiv/ var aBg=document.getElementById("bg"); /擷取bg這個ID,並給他取個名字為aBg/ aDiv.style.display="none"; /讓它的div隱藏/ aBg.href=""/讓它href為空白,不引入樣式表/ }
</script> <body><label onmouseover="bloc();" onmouseout="non()"><input type="checkbox">儲存密碼</label>/滑鼠放在此處可以出現效果/ <div id="div1">不要在公用場合儲存密碼</div> /此div預設為隱藏/ </body></html>