我在我的頁面上有超鏈接。當我將鼠標懸停在超鏈接上時,我想顯示div,並在鼠標懸停時將其隱藏。顯示/隱藏div onmouseover/onmouseout Javascript
我的HTML:
<a onmouseover="showDiv(this)" onmouseout="hideDiv(this)">
<img>
<div class="inner-block">
Content
</div>
</a>
的Javascript:
function showDiv(elem) {
elem.getElementsByTagName("div").style.visibility="visible";
}
function hideDiv(elem) {
elem.getElementsByClassName("inner-block2").style.visibility="hidden";
}
和CSS:
.inner-block {
visibility: hidden
}
我試過的getElementsByTagName,getElementsByClassName方法,無論我嘗試,我得到
Uncaught TypeError: Cannot set property 'visibility' of undefined
是A標籤的該div後關閉? – 2012-08-14 16:56:29
是的,關閉的標籤是在div- – deakolt 2012-08-14 16:57:37