How to get css hover values on click?(如何在点击时获得 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.
这篇关于如何在点击时获得 css 悬停值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在点击时获得 css 悬停值?


- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01