在此代码中:
$(document).ready(function()
{
$(".main_image .desc").show(); //Show Banner
$(".main_image .block").animate({ opacity: 0.65 }, 1 );
$(".image_thumb ul li:first").addClass('active');
$(".image_thumb ul li").click(function ()
{
var imgAlt = $(this).find('img').attr("alt");
var imgTitle = $(this).find('a').attr("rel");
var imgDesc = $(this).find('.block').html();
var imgDescHeight = $(".main_image").find('.block').height();
if ($(this).is(".active"))
{
return false;
}
else
{
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250,
function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom:"0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
}
});我改变了鼠标悬停时的点击,但我如何设置鼠标输出事件?提前感谢
发布于 2010-02-09 03:37:30
我没看到你的鼠标悬停事件处理程序。
如果您需要一个mouseover/mouseout处理程序,请使用hover(),如下所示:
$('.myelement').hover(
function() {
// my mouseover code
},
function() {
// my mouseout code
});编辑:
好的,我想我明白了。要绑定“mouseout”事件(或任何事件),请执行以下操作:
$('#myelement').bind('mouseout', function() {
// my code
});上一次编辑:
如果你想要“停止”当前的动画,那么你需要调用stop()。考虑以下示例:
$('#box').hover(
function() {
$(this).stop();
$(this).animate({height:300}, 1000);
},
function() {
$(this).stop();
$(this).animate({height:100}, 1000);
});
#box {
background: orange;
width: 100px;
height: 100px;
}
<div id='box'></box>如果当您“鼠标移出”时动画正在进行,调用$(this).stop()将暂停动画并启动“鼠标移出”动画。如果没有“mouseout”的动画,那么只需调用$(this).stop()。
https://stackoverflow.com/questions/2224265
复制相似问题