Tom*_*Tom 23 css jquery dom colors
我有跟随HTML
<div>This is some <span>special <a href="#">text</a></span> and it's super</div>
Run Code Online (Sandbox Code Playgroud)
和CSS
span {color:#333;}
a {color:#777;}
a:hover {color:#AAA;}
Run Code Online (Sandbox Code Playgroud)
我想知道我可以用什么设置一个函数,我可以提取<a>和<a>:悬停元素的颜色?
谢谢
RPM*_*984 48
对要检索的元素使用.css()方法.
在你的例子中:
var theColorIs = $('a').css("color");
Run Code Online (Sandbox Code Playgroud)
这将返回RGB中的颜色.