I'm new to Jquery so unsure how i would go about editing the code below to开发者_如何转开发 create a fade in when the class element is hovered over.
<script type="text/javascript">
<!--//--><![CDATA[//><!--
$(function() {
$('div.work-item').hover(function() {
}).hover(function() {
$(this).addClass("hover");
}, function(){
$(this).removeClass("hover");
});
});
//--><!]]>
Any pointers would be greatly appreciated.
Thanks!
I assume you're fading in some other element when the first is hovered over. Note that hover
takes two arguments: a function when the item is hovered over and another when the mouse moves out of the element. Since fadeIn/Out can take some time you might also want to look at the hoverIntent plugin to reduce inadvertent displays when simply mousing over the element and not actually intending to invoke the functionality.
$(function() {
$('div.work-item').hover(function() {
$('.selector-for-fadein-item').fadeIn('fast');
}, function(){
$('.selector-for-fadein-item').fadeOut('fast');
});
});
精彩评论