如何在点击时获得 css 悬停值?
跟进这个 问题,我还有另一个问题 - 单击文本链接时如何获取 css 悬停值?
Following up on this question, I have another issue - how to get css hover values when you click on a text link?
例如,我有文本悬停的这些值
For instance, I have these values for the text hover
a.test {
text-decoration:none;
}
a.test:hover {
text-decoration:none;
opacity:0.6 !important;
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=60)";
filter:alpha(opacity=60) !important;
}
<a href="#" class="test">Click Me</a>
这当然失败了!
$(".test").click(function(){
alert($(this).css());
return false;
})
有可能吗?
我遇到了类似的问题,但我不想使用那个插件.
I came across this similar question but I prefer not to use that plugin.
推荐答案
你可以做这样的事情,你可以创建自己的 CSS 属性列表,这些属性将应用于该元素(假设你有一个列表),然后循环通过他们:
You could do something like this, where you create your own list of css properties that would be applied to that element (assuming you had a list) and then cycle through them:
var cssList = ['text-decoration','opacity','filter'];
$(".test").click(function(){
for(x in cssList){
alert($(this).css(cssList[x]));
}
return false;
})
示例:http://jsfiddle.net/jasongennaro/GmWCz/
当然,如果你需要的话,你可以一直使用它并添加所有属性.
Of course, you could take this all the way and add all the properties, if that is what you needed.
相关文章