0

我有以下代码可以正常工作,只是没有触发鼠标悬停,因此图标留在鼠标悬停阶段。

我从其他来源拼凑了这段代码,所以我确信它可以被简化。任何帮助,将不胜感激!

jQuery(function(jQuery){
    jQuery('a.fav_me').live('click', function(){
        var self = this;
        jQuery.get(self.href, {
            theID: self.id.substring(3)
        }, function(data){
            jQuery(self).html('<img src="/images/icons/liked-icon.png" alt="you already like this member" title="you already like this member"/>').toggleClass('fav_me fav_delete');
        });
        return false;
    });
    jQuery('a.fav_delete').live('mouseover', function(){
        var entryID = jQuery(this).attr("rel");
        jQuery(this).html('<img src="/images/icons/unlike-lrg.png" alt="remove your like" title="remove your like"/>').attr('href', 'includes/favourite-add/' + entryID + '/delete/');
    }).live('mouseout', function(){ 
        jQuery(this).html('<img src="/images/icons/liked-icon.png" alt="you already like this member" title="you already like this member"/>');
    }).live('click', function(){
        var entryID = jQuery(this).attr("rel");
        var self = this;
        jQuery.get(self.href, {
            theID: self.id.substring(3)
        }, function(data){
            jQuery(self).html('<img src="/images/icons/hug-icon-lrg.png" alt="add to likes" title="like this member"/>').toggleClass('fav_delete fav_me').attr('href', 'includes/favourite-add/' + entryID);
        });
        return false;
    });
});
4

1 回答 1

0

尝试“mouseleave”而不是“mouseout”

于 2012-10-03T11:03:28.737 回答