jQuery noob:在另一个元素悬停时更改元素的边框颜色 [英] jQuery noob: change border color of element on hover of another element

查看:133
本文介绍了jQuery noob:在另一个元素悬停时更改元素的边框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尽力解释我的意思,但是有一种更简单的方法:单击此处以进行jsfiddle示例 e.

I'd try to explain what I mean, but there is an easier way: click here for jsfiddle example.

基本上,我希望将productOptionsMenu悬停在div上时div rfrsh_btn的边框颜色更改.

Basically I want the border color of the div rfrsh_btn to change when productOptionsMenu is hovered over.

我正在将jQuery与.noConflict变量一起使用,因为此站点还使用了原型.

I'm using jQuery with the .noConflict var because this site also uses Prototype.

jQuery:

var $j = jQuery.noConflict();

$j(".productOptionsMenu").hover(
    function () {
        $j(#rfrsh_btn).css({"border-color":"#85c222"});
    };
);

谢谢:)

推荐答案

var $j = jQuery.noConflict();

$j(".productOptionsMenu").hover(
    // hover begin (mouse-in)
    function () {
        $j("#rfrsh_btn").css({"border-color": "#85c222"});
    },
    // hover end (mouse-out)
    function () {
        $j("#rfrsh_btn").css({"border-color": ""});
    }
);

我建议分别使用addClass()removeClass()代替css().

Instead of css() I recommend using addClass() and removeClass(), respectively.

这篇关于jQuery noob:在另一个元素悬停时更改元素的边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆