jQuery更新实际的CSS [英] jQuery to update actual CSS

查看:105
本文介绍了jQuery更新实际的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先关闭:我知道jQuery.css()函数,但它在我的情况下不起作用。我将解释原因。

First off: I'm aware of the jQuery.css() function, but it doesn't work in my case. I'll explain why.

我有一个jQuery颜色选择器用于更改网站的突出显示。我想将该颜色选择器应用于仅在悬停时显示的元素的边框。

I have a jQuery color picker being used to change the highlighting of a website. I want to apply that color picker to the border of an element which only shows on hover.

jQuery.css()函数仅适用它找到的元素的CSS,并且不适用于:hover CSS属性。

The jQuery.css() function only applies the CSS to elements it finds, and does not work on the :hover CSS attribute.

我试过了添加一个我在悬停时切换的CSS类,但它回到了同样的问题:我正在尝试仅更改悬停值。

I've tried adding a CSS class which I toggle on the hover, but it comes back to the same problem: I'm trying to change ONLY the hover value.

必须有一种方法,但我现在一直在寻找StackOverflow和Google一小时的大部分时间,所以我正在调用 xkcd#627

There's got to be a way to do this, but I've been searching StackOverflow and Google for the better part of an hour now, so I'm invoking xkcd #627

推荐答案

使用悬停事件以获得相同的结果。

Use the hover event to achieve the same results.

$('selector').hover( function(){
    //A function to execute when the mouse pointer enters the element.
    $(this).css('property','value');
}, function(){
    //A function to execute when the mouse pointer leaves the element.
    $(this).css('property','value');
});

这篇关于jQuery更新实际的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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