Read css scale value using JS or Jquery

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

I have this div

How do I get the

transform: scale(x,y) 
4条回答
  •  自闭症患者
    2021-01-25 02:59

    var m = $('#id').css('transform');
    var mt = m.substring(m.indexOf('(') + 1, m.indexOf(')')).split(',');
    // or else: var mt = m.substring(7, m.length - 1).split(',');
    console.log(mt[0], mt[3]);
    
    

    You can put a plus sign in front of the array elements to ensure they are treated as numeric.

提交回复
热议问题