如何获取css悬停值点击? [英] How to get css hover values on click?
本文介绍了如何获取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.
这篇关于如何获取css悬停值点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文