In JQuery, Is it possible to get callback function after setting new css rule?

后端 未结 6 1112
一生所求
一生所求 2020-12-03 17:05

I have $(\'.element\').css(\"color\",\"yellow\") and I need that next event was only after this one, something looks like $(\'.element\').css(\"color\",\"

6条回答
  •  情书的邮戳
    2020-12-03 17:12

    Yes, it is possible. You need to use the jQuery animate function with a duration of 0:

        $('#my-selector').animate({
            'my-css-property-name': 'my-css-property-value'
        }, {
            duration: 0,
            done: function(animation, jumpedToEnd) {
                // Your callback here
            }
        })
    

    To know more about the done function parameters, check the documentation.

提交回复
热议问题