jQuery菜单悬停,但不要点击

时间:2011-06-06 13:14:17

标签: javascript jquery href html

HTML结构:

<a class="fadeThis"  id="paperoff" href="#"><span id="paperon" class="hover">News</span></a>

JAVASCRIPT:

$('.fadeThis > .hover').empty();    

$('.fadeThis').each(function () {
    var text = $(this).text();
    $(this).append(''+text+'');

    var $span = $('> span.hover', this).css('opacity', 0);  
    $(this).hover(function () {
        $span.stop().fadeTo(500, 1);
    }, function () {    
        $span.stop().fadeTo(500, 0);
    }).click (function () {
        // HERE SOMETHING THAT TELLS TO NOT FADE BACK THE SPAN (ONLY FOR THE CLICKED DIV).
});

});

1 个答案:

答案 0 :(得分:1)

你的问题不是很清楚,但是你想要这样的东西吗?

var fadeBlock = false;
$(this).hover(function () {
$span.stop().fadeTo(500, 1);
}, function () {
    if (!fadeBlock) {
      $span.stop().fadeTo(500, 0);
} else { fadeBlock = false;}
}).click (function () {
   fadeBlock = true;
});