鼠标在div描述框粘贴

时间:2012-07-06 18:37:26

标签: jquery

因此,如果您访问www.graysonearle.com/newtest,您将看到我的网站正在进行中。我正在使用一个jQuery脚本,当你将鼠标悬停在盒子上时会弹出项目描述。问题是有时候描述会保留在mouseOut之后,即使你再次回到它们上面也是如此。而其他时候,描述不会弹出。如果快速移动鼠标,则更容易破碎。这是jQuery:

$(window).load(function() {
    // For each instance of p.caption
    $("p.caption").each(function() {
        // needs a 1px bump
        $(this).children("span").css({
            "margin-left": "1px"
        });
        $(this)
        // Add the following CSS properties and values
        .css({
            // Height equal to the height of the image
            "height": $(this).children("img").height() + "px",
            // Width equal to the width of the image
            "width": $(this).children("img").width() + "px"
        })
        // Select the child "span" of this p.caption
        // Add the following CSS properties and values
        .children("span").css(
        // Width equal to p.caption
        // But subtract 20px to callibrate for the padding
        "width", $(this).width() - 10 + "px")
        // find the <big> tag if it exists
        // And then add the following div to break the line
        .find("i").before('<div class="clear"></div>');
        // When you hover over p.caption
        $("p.caption").hover(function() {
            // Fade in the child "span"
            $(this).children("span").stop().fadeTo(200, 1);
        }, function() {
            // Once you mouse off, fade it out
            $(this).children("span").fadeOut(200); // removed "stop()" before fadeout
        });
        // End $(this)
    });
});​

0 个答案:

没有答案