Reputation: 969
I have an anchor tag, which when hovered, I want a certain div ("mark") to show up. The div is NOT inside the anchor tag.
The HTML is as follows:
<a href="#" class="mark"></a>
<div class="icontent">
<p>
lorem ipsum dolor sit amet......
</p>
</div>
When mouse is hovered on ".mark", ".icontent" should show up. When mouse is out, ".icontent" should hide again. Is it also possible to add a 1 second transition to it?
Thanks
Upvotes: 3
Views: 21477
Reputation: 47685
$(".mark").on({
mouseover: function() {
$(".icontent").stop().show(1000);
},
mouseout: function() {
$(".icontent").stop().hide(1000);
}
})
Upvotes: 3
Reputation: 191819
$(".mark").hover(function () {
if (!$(".icontent").is(":animated")) {
$(".icontent").show('slow');
}
}, function () {
$(".icontent").stop().hide('slow');
});
You could also use mouseover
and mouseout
separately. The :animated
and .stop
additions are done to prevent wise guys from moving their mouse over and o ut of the anchor repeatedly.
Upvotes: 1
Reputation: 354
$(".mark").mouseover(function() {
$('.icontent').fadeIn(1000);
}).mouseout(function(){
$('.icontent').fadeOut(1000);
});
Upvotes: 0
Reputation: 3532
Here you are
HTML
<a href="#" class="mark">hover anchor</a>
<div class="icontent">
<p>
lorem ipsum dolor sit amet......
</p>
</div>
JS
(function(){
var del = 200;
$('.icontent').hide().prev('a').hover(function(){
$(this).next('.icontent').stop('fx', true).slideToggle(del);
});
})();
Example http://jsbin.com/evehat/1/edit
Upvotes: 2
Reputation: 1186
hover() will work nicely here:
$('.mark').hover(function() {$('.icontent').show(1000)}, function() {$('.icontent').hide(1000)});
Upvotes: 5
Reputation: 718
$('.mark').hover(function() {$('.icontent')).fadeIn(1000)},
function(){$('.icontent').fadeOut(1000)});
This should work :)
Upvotes: 0