<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=Edge,chrome=1"/>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>图片点击一次就旋转90度</title>
<script src="js/jquery-1.11.3.js" type="text/javascript"></script>
<style>
.rotate90{
transform:rotate(90deg);
}
.rotate180{
transform:rotate(180deg);
}
.rotate270{
transform:rotate(270deg);
}
.rotate360{
transform:rotate(360deg);
}
</style>
<script>
$(function () {
var i = 0;
var classes = [‘rotate90‘, ‘rotate180‘, ‘rotate270‘, ‘rotate360‘];
$(‘img‘).on(‘click‘,function(){
var $this = $(this);
$this.addClass(classes[i++ % 4])
.removeClass(function(idx, cls) {
var classes = cls.split(‘ ‘);
return classes.length > 1 ? classes[0] : ‘‘;
});
});
})
</script>
</head>
<body>
<img src="image/20150921093021174.jpg" alt="美女"/>
</body>
</html>