jQuery Menu Hover, but don't at click
HTML Structure:
<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).
});
});
Your question is not very clear, but do you want someting like this?
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;
});
精彩评论