2011-01-28 125 views
0

這就是我的代碼所做的事情:if #placeBookmark具有類.placing,我徘徊在#bookmarkThis淡出的段落。 #bookmarkThis僅僅是一個帶有「bookmark this」字樣的div,當頁面加載時,這個div被添加到頁面中,並且集中在被徘徊的段落上,然後在鼠標懸停時淡出。Jquery:當鼠標懸停在P上時,div會在P的中心淡出,但當鼠標懸停在該div上時,會產生鼠標移出效果

我的問題/問題:當我將鼠標懸停在該段落上時,它會淡入該段落並居中,但當鼠標移過#bookmarkThis(這是淡入淡出的div)時,它會淡出,就像我把這一段刪掉了。我如何保持#bookmarkThis從搞亂我的段落懸停?

注:#bookmarkThis被附加在網頁加載的身體(這不是P的孩子),相對於P鍵,然後被定位徘徊。

enter image description here

$('p').hoverIntent(function() { 
    var myObject = $('#bookmarkThis') 
    var topp = $(this).offset().top + ($(this).height()/2) - (myObject.outerHeight()/2) 
    var leftt = $(this).offset().left + ($(this).width()/2) - (myObject.outerWidth()/2) 

    if ($('#placeBookmark').hasClass('placing')) { 
     $(this).animate({color: "#999999", backgroundColor: "#f5f5f5"}, 400) 
     $('#bookmarkThis').css({'left': leftt, 'top':topp}).fadeIn(200) 
    } 
}, function() { 
    $(this).stop().animate({color: "#333", backgroundColor: "#fff"}, 200) 
    $('#bookmarkThis').fadeOut(200) 

}); 
+0

你可以做的是將這個按鈕的書籤追加到< – Kapil 2011-01-28 10:34:02

回答

1

您可以將書籤這個按鈕段落,然後將其刪除,一旦你懸停了款。

相關問題