我正在使用JavaScript工具欄。這個工具欄的常規高度是50px。在鼠標懸停時,它的高度變化爲500px。但是,在這個工具欄上,有一個小小的圖釘。我的目的是使這一形象改變工具欄div的高度500像素,讓它保持下去。目前,我可以改變工具欄的div與圖像,但它的onmouseout變回原來的50像素高度。工具欄的JavaScript引腳到/ onmouseover事件衝突
我怎樣才能讓這個被點擊的引腳圖像時,該功能鼠標移開停止工作,直到圖像再次點擊?
如果有幫助,這是我的代碼:
//Pin to Image
<img class="pin" onClick = "document.getElementById('toolbar').style.height
= '500px';" src="images/pin.png" width="20px" height="20px" />
//JavaScript for mouseoverevent
$(document).ready(function() {
$("#toolbar").hover(
//on mouseover
function() {
$("#toolbar").animate({
height: '550'
}, 'slow');
},
//on mouseout
function() {
$(this).animate({
height: '-=500px'
}, 'slow');
}
);
});
這並獲得成功!謝謝 – Resitive