Reputation: 67
Why doesn't button make cube rotate?
I am adding +=45deg to it!
Here's the code:
jQuery:
$(document).ready(function(){
$('button').click(function(){
$('#cube').css('-webkit-transform','rotateY(+=45deg)');
});
});
Html:
<button>rotate</button>
<div id="cube">
</div>
css:
#cube {
display: block;
width: 250px;
height: 250px;
background: #66F;
}
jsfiddle: http://jsfiddle.net/ysLet/
Upvotes: 1
Views: 1310
Reputation: 810
seems like the += operator does not work in the css line
$(document).ready(function(){
deg = 0;
$('button').click(function(){
deg += 45;
$('#cube').css('-webkit-transform','rotateY('+deg+'deg)');
});
});
this did the trick...
Upvotes: 2