Change CSS class properties with jQuery

后端 未结 8 1630
心在旅途
心在旅途 2020-11-29 04:59

Is there a way to change the properties of a CSS class, not the element properties, using jQuery?

This is a practical example:

I have a div with class

8条回答
  •  没有蜡笔的小新
    2020-11-29 05:39

    Didn't find the answer I wanted, so I solved it myself:
    modify a container div!

    This div gets scaled on hover
    This div does not

    css you want to persist after executing $target.css()

    .content:hover {
        transform: scale(1.5);
    }
    

    modify content's containing div with css()

    $(".rotation").css("transform", "rotate(" + degrees + "deg)");
    

    Codepen example

提交回复
热议问题