Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add css transform to the current transform value Using jquery?

Currently I have a class with transform value rotate(57deg), when alert

$(".div-1").css("transform") it is giving matrix value.

<style> 
 .div-1{
     transform: rotate(57deg);
     }                 
</style>   
<div class="div-1">Test</div>

I need to add scale(-1, 1) to the existing transform value using Jquery

. so .div-1 transform value become div-1 { transform: scale(-1, 1) rotate(57deg); } How to do this ? Here 57 is just a number , it will change always. so what I need is add scale( -1 , 1) to the current transform value . Please help .

like image 239
Jafar tm Avatar asked Dec 28 '16 06:12

Jafar tm


2 Answers

you can do something like this :

var css = $('.div-1').css("transform");
css = css+" scale(-1,1)";
$('.div-1').css('transform',css);
like image 111
Aman Goyal Avatar answered Oct 22 '22 23:10

Aman Goyal


<style>
    div {
        -ms-transform: rotate(57deg); // IE 9  
        -webkit-transform: rotate(57deg); // Chrome, Safari, Opera  
        transform: rotate(57deg);
    }
</style>
like image 1
Ramya Roy Avatar answered Oct 22 '22 22:10

Ramya Roy