js 实现点击一次图片旋转90度,再点击再转90度

<!doctype html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>旋转图片</title>
 <script>
 window.onload = function(){
 var current = 0;
 document.getElementById('xz').onclick = function(){
 current = (current+90)%360; 
 document.getElementById('target').style.transform = 'rotate('+current+'deg)';
 }
 };
 </script>
</head>
<body>
<img id ="target" src="https://pdbn.top/wp-content/themes/pdbn/img/pdbntop128.png" alt="">
<button id ="xz">旋转</button>
</body>
</html>

[runcode]< !doctype html>



旋转图片






[/runcode]