开发菜单时,我在一些很简单的事情上遇到了一些麻烦(显然不适合我)。

EXPLANATION IMAGE http://img80.imageshack.us/img80/7060/hoverdivexpl.jpg

背景/菜单按钮是所有图像。

我已经尝试使用其他StackOverflow(和其他)用户的建议来解决该问题,但不知道如何进行。一旦工作,将鼠标悬停在按钮上,但不会切换回div的背景色;然后可以工作,但是什么都不会消失。

我对Web开发/ jQuery有一定的基础知识,但是我很困惑。

最佳答案

对于这两个按钮,类似

$(selector1).hover(
    // Function to call when mouse enters element
    function() {
        // Animate to set new background in 100 milliseconds
        $(this).animate({'background': 'A'},100);
        $(bigdivselector).animate({'background': 'A'},100);
    },
    // Function to call when mouse leaves element
    function() {
        $(this).animate({'background': 'defaultBG'},100);
        $(bigdivselector).animate({'background': 'defaultBG'},100);
    },
);


显然,您必须用适当的值替换选择器和背景。

关于jquery - 更改另一个div的背景,将鼠标悬停在多个按钮上,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8908656/

10-11 12:51
查看更多