How to get css hover values on click?

前端 未结 4 792
你的背包
你的背包 2021-01-28 12:08

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

4条回答
  •  醉话见心
    2021-01-28 12:53

    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;
    })
    

    Example: 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.

提交回复
热议问题