我如何使用Jquery改变图像与滑动过渡悬停?我在互联网上搜索过,但我找不到一个工作代码。我找到的所有代码都使用渐入或渐出。非常感谢!
这是我找到的代码,但它使用淡入和淡出:
<script>
$(function() {
$('.change').mouseenter(function(){
$(this).slideUp('fast', function(){
$(this).attr('src', $(this).data('on'));
$(this).fadeIn();
});
});
$('.change').mouseleave(function(){
$(this).slideUp('fast', function(){
$(this).attr('src', $(this).data('off'));
$(this).fadeIn();
});
});
});</script>
AND html:
<img class="change" src="images/portofoliu/next.gif" data-on="images/portofoliu/prev.gif" data-off="images/portofoliu/next.gif">
<div id="clickme">
Click here
</div>
<img id="book" src="book.png" alt="" width="100" height="123" />
$('#clickme').hover(function() {
$('#book').slideUp('slow', function() {
// Animation complete.
});
});
http://jsfiddle.net/GFdW5/3/http://api.jquery.com/slideUp/EDIT:最终解决方案:http://jsfiddle.net/hellomynameisluc/frTFw