為什么我的$(closeBtn).style.display='block';無效呢?
<!DOCTYPE html>
<html>
<head>
? ? <meta charset="UTF-8">
? ? <title>廣告小窗口伸縮</title>
? ? <style>
? ? ? ? *{margin:0;padding:0;}
? ? ? ? h2,h3{text-align:center;font-size:14px;}
? ? ? ? h3{padding-top:5px;}
? ? ? ? .content_main{background:#8A7F78;width:1024px;height:800px;margin:0 auto;}
? ? ? ? .RB_ad{
? ? ? ? ? ? position:fixed;
? ? ? ? ? ? right:0;
? ? ? ? ? ? bottom:0;
? ? ? ? ? ? text-align:center;
? ? ? ? ? ? background:#CCC;
? ? ? ? ? ? font-size:14px;
? ? ? ? }
? ? ? ? .clickMe{height:24px;line-height:24px;background:#CCC;}
? ? ? ? .showPic{display:none;}
? ? ? ? .clickMe{position:relative;}
? ? ? ? .clickMe a{background:url(images/icon.jpg) no-repeat -399px -19px;width:16px;height:16px;display:none;position:absolute;top:5px;right:5px;}
? ? ? ? .clickMe a:hover{background-position:-343px -19px;}
? ? ? ? .show{display:block;}
? ? ? ? .hide{display:none;}
? ? </style>
? ? <script>
? ? ? ? window.onload=function(){
? ? ? ? ? ? var $=function(id){//$只是一個變量。
? ? ? ? ? ? ? ? return document.getElementById(id);
? ? ? ? ? ? }
? ? ? ? ? ? $("clickMe").onmouseover = function(){
? ? ? ? ? ? ? ? $("showPic").className='show';
? ? ? ? ? ? ? ? $("closeBtn").style.display='inline-block';
? ? ? ? ? ? }
? ? ? ? ? ? $("closeBtn").onclick = function(){
? ? ? ? ? ? ? ? $("showPic").className='hide';
? ? ? ? ? ? ? ? $("closeBtn").style.display='none';
? ? ? ? ? ? }
? ? ? ? }
? ? </script>
</head>
<body>
為什么我的$(closeBtn).style.display='block';無效呢?
改為$(closeBtn).style.display='inline-block';才行。
2015-01-19
你都沒有寫 DOM 元素啊啊啊啊啊
2015-01-19
$() 用錯了, 記得 jquery 中獲取元素 ? ,
??ID : ?$('#ID')
? class: $('.class')
? tag: ?$('tag')
很久以前我剛學也犯這個錯誤的,很正常的