2016-05-08 27 views

回答

1

我希望這會引導你完成它

$(document).ready(function(){ 
 
    $("#rotateButton").click(function(){ 
 
     var x= $("#rotateInput").val();  
 
    $("#rotate").css('transform','rotate(' + x + 'deg)'); 
 
     
 
    }); 
 
});
#rotate{ 
 
    background: url('https://cdn2.iconfinder.com/data/icons/faceavatars/PNG/D04.png'); 
 
    width: 180px; 
 
    height:150px; 
 
    background-repeat:no-repeat; 
 
    margin:40px auto; 
 
    
 
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 

 
    <div id="rotate"></div> 
 

 
<input id="rotateInput" type="text" value="0"> 
 
<button id="rotateButton">Rotate It</button> 
 

 

 

+0

非常感謝,這正是我想要的 – johndoe

+0

歡迎您投上一票。 –