Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8600995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:44:34+00:00 2026-06-12T01:44:34+00:00

I have a div, when you click it I want it to rotate and

  • 0

I have a div, when you click it I want it to rotate and then when you click it again it rotates back, a toggle. I’m doing this with CSS transforms, and I need to add the classes also with jquery. I have the classes stored in vars and then am trying to apply them. Here is the jfiddle I’m working on, thanks for your help in advance.

http://jsfiddle.net/nzLUS/3/

here is the code:

<div id="beffects_of_yoga_info" style="width:50px;height:50px;background:red;"></div>

jquery:

$(document).ready(function() {

var css_info_timing = {
"-webkit-transform": "all 1s ease;"
}
var css_info_rotate = {
"-webkit-transition": "rotate(150deg)"
}

$("#effects_of_yoga_info").css(css_info_timing);

$("#effects_of_yoga_info").click(function () {
$("#effects_of_yoga_info").toggleClass(css_info_rotate);
});
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:44:35+00:00Added an answer on June 12, 2026 at 1:44 am

    Here you’re using toggleClass, but you’re actually trying to toggle a property!

     $("#effects_of_yoga_info").toggleClass(css_info_rotate);
    

    First of all, add this css class:

    .rotated {
        -moz-transform:rotate(150deg);
        -webkit-transform:rotate(150deg);
        -o-transform:rotate(150deg);
        -ms-transform:rotate(150deg);
        transform:rotate(150deg);
        -moz-transition:all 1s ease;
        -webkit-transition:all 1s ease;
        -o-transition:all 1s ease;
        -ms-transition:all 1s ease;
        transition:all 1s ease;
    }​
    

    Then this jQuery listener:

    $("#effects_of_yoga_info").click(function () {
        $("#effects_of_yoga_info").toggleClass('rotated');
    });
    

    Check the demo


    Edit

    As you don’t have access to CSS, use this code to add the rule dinamically:

    $("<style type='text/css'>.rotated{-moz-transform:rotate(150deg);-webkit-transform:rotate(150deg);-o-transform:rotate(150deg);-ms-transform:rotate(150deg);transform:rotate(150deg);-moz-transition:all 1s ease;-webkit-transition:all 1s ease;-o-transition:all 1s ease;-ms-transition:all 1s ease;transition:all 1s ease}</style>").appendTo("head");
    
    $("#effects_of_yoga_info").click(function () {
        $("#effects_of_yoga_info").toggleClass('rotated');
    });
    

    Another demo

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a div click-able and but inside this <div> i have
I have a div element. I need to catch a mouse click on this
hi i have this html code : <div id=#div><a href=>Test</a></div> i want attach click
I have a div that I want when user click on a button slideUp
I have a DIV which I want to be removed when I click a
I have a div, and when you click on it, used toggle() and shows
I have div-elements when i click on DIV, i add class selected of this
I have following DIV . I want to display the DIV after button click
I have a div in left side, I want once click on div slide
hi i have following code in this i have div card-208 on click i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.