html代码:
<img style="max-width: 700px; transform: rotate(360deg);" src="/image/test1.img" class="image1">
<input type="hidden" value="0" name="tran_num1">
<a href="javascript:;" class="rotate" image_id="1">旋转</a>
js代码:
$(‘.rotate‘).click(function () {
var id = $(this).attr(‘image_id‘);
var num = $(‘input[name=tran_num‘ + id + ‘]‘).val();
var num = Number(num) + 1;
var i = 90 * num;
$("#image"+id).css("transform", "rotate(" + i + "deg)");
if (num == 4) {
var num = 0;
}
$(‘input[name=tran_num‘ + id + ‘]‘).val(num);
})
时间: 2024-10-23 16:49:32