Read css scale value using JS or Jquery

后端 未结 4 503
南笙
南笙 2021-01-25 02:24

I have this div

How do I get the

transform: scale(x,y) 
4条回答
  •  温柔的废话
    2021-01-25 02:46

    and then

    var vals = $('#container').css('transform').replace(/\(|\)|scale/g,'').split(',')
    

    Now, you have the scale values in vals as string, just parse parseFloat(vals[0]) and parseFloat(vals[1]) to number to get the value of x and y

提交回复
热议问题