如何獲取此腳本,點擊功能轉換爲懸停功能效果。jquery hover image保持內容打開,直到鼠標移出
enter code here
http://jsfiddle.net/K55ct/78/
我想徘徊的小方塊,並能夠在鼠標下面的DIV內容,只要我願意,然後對小鼠進行再次有DIV隱藏
如何獲取此腳本,點擊功能轉換爲懸停功能效果。jquery hover image保持內容打開,直到鼠標移出
enter code here
http://jsfiddle.net/K55ct/78/
我想徘徊的小方塊,並能夠在鼠標下面的DIV內容,只要我願意,然後對小鼠進行再次有DIV隱藏
將html更改爲此
<div id="footerSlideContainer">
<div id="footerSlideButton"></div>
<div id="footerSlideContent">
<div id="footerSlideText">
<div id="footer_higher">
<div id="footer_content">
<div class="footbox"></div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
現在按鈕位於容器內。現在您可以使用容器作爲$('#footerSlideContainer').hover()
函數。該功能允許兩個參數,在鼠標上的一個函數和一個鼠標了,所以你jQuery的部分應該是這樣的:
jQuery(function($) {
$('#footerSlideContainer').hover(function() {
$('#footerSlideContent').animate({ height: '230px' });
$(this).css('backgroundPosition', 'top left');
},
function() {
$('#footerSlideContent').animate({ height: '0px' });
$(this).css('backgroundPosition', 'top left');
}
);
});
演示:jsFiddle
編輯 爲了保持顏色更改CSS爲:
#footerSlideContainer{position:fixed;top:50px;width:360px;left:0px}
#footerSlideButton{background:red;position:fixed;top:0;left:0px;width:50px;height:50px}
#footerSlideContainer:hover #footerSlideButton{background:green}
#footerSlideContent{height:0;background:blue}
謝謝,在我原來的帖子中,我沒有提到,我想保持懸停狀態的顏色相同,當我滾動div。懸停的顏色是綠色的,所以我會怎麼做。我知道點擊功能,你添加一個toggleclass.clicked – 2013-03-17 22:15:45
丹尼爾非常感謝工作!我插入了一個登錄表單框http://jsfiddle.net/MwChT/80/當您將鼠標懸停在下拉選擇框上時,您是否知道如何防止div關閉? – 2013-03-18 14:52:50
在Safari看這個小提琴看起來很好,但在Firefox中它是一團糟。 – 2013-03-19 18:55:51
爲什麼人們更喜歡downvoting而不是回答這個問題..? – writeToBhuwan 2013-03-17 18:18:31