ItSolutionStuff.com

JQuery Rotate Image Animation Example Code

By Hardik Savani • July 4, 2023
jQuery

In this example, we will create simple example of image rotate 90 degrees with css animation using javascript. you can easily image rotate 90 degrees, 180 degrees or 360 degrees using transform css with jquery animate function.

there are several plugin available for rotate image but i will suggest you using jquery animate and using CSS3 transform property. you need to just give value with deg as property. it will make simple and customize.

bellow example, when you click on button image will rotate each time 90 deg. you can simple copy html file and check it. it is a very simple example, just check bellow code.

Example:

<!DOCTYPE html>

<html>

<head>

<title>Jquery rotate image animation example - ItSolutionStuff.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

</head>

<body>

<img src="https://itsolutionstuff.com/frontTheme/images/logo.png">

<button>Rotate image</button>

<script type="text/javascript">

var tmpAnimation = 0;

$("button").click(function(){

var element = $("img");

tmpAnimation = tmpAnimation + 90;

$({degrees: tmpAnimation - 90}).animate({degrees: tmpAnimation}, {

duration: 2000,

step: function(now) {

element.css({

transform: 'rotate(' + now + 'deg)'

});

}

});

});

</script>

</body>

</html>

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

JQuery Redirect to Another Page After 5 Seconds Example

Read Now →

Bootstrap Star Rating using Bootstrap-star-rating JS Example

Read Now →

How to Create Custom Scrollbar using JQuery?

Read Now →

JQuery Animated Typing Effect using Typed JS Example

Read Now →

How to Remove Comma from String in JQuery?

Read Now →

JQuery Add Remove Input Fields Dynamically Example

Read Now →

Bootstrap Form Validation using Validator.js Example

Read Now →

Bootstrap Fancy Alert Box using SweetAlert Example

Read Now →

JQuery Chosen Multi Select Dropdown Example

Read Now →

JQuery Timepicker with AM PM Format Example

Read Now →

Bootstrap Notification Popup Box using Bootstrap-growl JS Example

Read Now →

JQuery Tag Input Plugin Example Code

Read Now →

How to Redirect Another Web Page in JQuery?

Read Now →

How to Check Object is Empty or Not in JQuery?

Read Now →