-1

Possible Duplicate:
How do I access style properties of pseudo-elements with jQuery?

First,hover the block will rotation 40deg!!

How to change .block:hover from 40deg to 80deg when click button ??

CSS

<style type="text/css">

.block{
    -moz-transition:All 1s ease;
    -moz-transform: rotate(1deg);

    width:200px; height:100px;
background-color:#999;
}
.block:hover{
    -moz-transform: rotate(40deg);
}

</style>

HTML

<button id="change">&raquo; Run</button><br><br>
<div class="block">TEST</div>

JS

<script>
$("#change").click(function(){

//???

});
</script>
Community
  • 1
  • 1
user962408
  • 147
  • 1
  • 12

4 Answers4

1

Change the class instead

<style type="text/css">

.block, .block-80{
    -moz-transition:All 1s ease;
    -moz-transform: rotate(1deg);

    width:200px; height:100px;
background-color:#999;
}
.block:hover{
    -moz-transform: rotate(40deg);
}
.block-80:hover{
    -moz-transform: rotate(80deg);
}

</style>

JS

<script>
$("#change").click(function(){

  $('.block').removeClass('block').addClass('block-80');

});
</script>
Maxim Krizhanovsky
  • 25,260
  • 5
  • 51
  • 86
0

You can add a class on click which have the required style, try this

.rotate80deg{
    -moz-transform: rotate(80deg);
}


$("#change").click(function(){

   $(this).addClass('rotate80deg');

});
ShankarSangoli
  • 68,720
  • 11
  • 89
  • 123
0

You could do it by adding a class via jQuery.

Example:

jQuery

$('#change').click(function(){
    $(this).toggleClass('on');
});

CSS

.on {
    -moz-transform: rotate(80deg);
}

jsFiddle example here: http://jsfiddle.net/peduarte/XFPPn/

peduarte
  • 1,647
  • 3
  • 16
  • 24
0

Take a look at this jquery addin that can help you with the transform property in css jquery-css-transform

Jose Vega
  • 9,950
  • 7
  • 39
  • 57