我正在研究一些HTML,我希望這樣做,以便在將鼠標移到div上時,它將沉沒大約10 px,並且單擊它時會完全沉沒。我之前用div沒有任何鏈接(<a>
)或文本(<p>
),並且它工作得很好。但在我的網站(www.metatronaut.com)它根本沒有下沉。在我的javascript代碼:如何使鼠標懸停在水槽上,然後單擊
$(document).ready(function() {
$('tag').mouseenter(function() {
$(this).animate({
height: '-=20px'
});
});
$('tag').mouseleave(function() {
$(this).animate({
height: '+=20px'
});
});
$('tag').click(function() {
$(this).animate({
height: '-=250px'
});
});
});
(的div是250像素)
這裏是我的HTML標籤是如何上市。
<td>
<a href="https://www.twitter.com/metatronstudios">
<div id="twitter">
<p>Twitter</p>
</div>
</a>
</td>
而CSS
div {
height:250px;
width:250px;
}
table {
margin:auto;
}
a {
font-size:24px
text-decoration:none;
color:#FFFFFF;
}
#twitter {
background-color:#11CDFB;
}
任何想法是怎麼回事?或者我應該把什麼標籤放在JS? (我已經使用了a,div,td和p,其中沒有一個能夠工作。)
謝謝!
薩姆
您可以定義「匯」 ?把整個股票下移?把它縮短一點?究竟是什麼? –
你想要解決什麼問題:'$('tag')' - 你在頁面上沒有任何''元素。你是否想讓你的div移動?然後選擇器需要'$('div')。mouseenter(...)' –
'tag'就是一個例子。目前我有'div'。 – user3380708