I am trying to rotate a div using an onclick function with js but when I click my button nothing happens. Any suggestions? I want to be able to keep clicking the button for a 90 degree rotation, not just once.
<html>
<form action="#" method="post">
<input type="url" name="imglink" id="imglink" placeholder="Insert image URL here" /><br>
<input type="button" value="Show Image" id="btn1" />
</form>
<div id="photo"></div>
<script>
document.getElementById('btn1').addEventListener('click', function(){
document.getElementById('photo').innerHTML = '<img src="'+ document.getElementById('imglink').value +'" alt="Image" />';
});
</script>
<input type="button" value="Rotate" onclick="rotatePhoto()">
<script>function rotatePhoto(){
var img = document.getElementById("photo");
img.rotate(20*Math.PI/90);
}
</script>
</html>