首先:我知道 jQuery.css() 函数,但它不适用于我的情况。我会解释原因。
我有一个 jQuery 颜色选择器用于更改网站的突出显示。我想将该颜色选择器应用于仅在悬停时显示的元素的边框。
jQuery.css() 函数只将 CSS 应用到它找到的元素,而不作用于 :hover
CSS 属性。
我尝试添加一个 CSS 类,我在悬停时切换它,但它又回到了同样的问题:我试图仅更改悬停值。
一定有办法做到这一点,但我已经在 StackOverflow 和 Google 上搜索了一个小时的大部分时间,所以我调用了 xkcd #627
最佳答案
使用 hover事件以达到相同的结果。
$('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');
});
关于javascript - jQuery 来更新实际的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20985504/