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 7956987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:09:42+00:00 2026-06-04T04:09:42+00:00

I am attempting to make an element shake upon hover without using jQuery UI

  • 0

I am attempting to make an element shake upon hover without using jQuery UI and have come across the following code, however I cant seem to figure out how to trigger on hover, this code has a Random effect and it confuses me every time I try to diffuse it. I’m trying to get them to animate one at a time not altogether

http://jsfiddle.net/g6AeL/

   $(function() {
      var interval = 10;
      var duration= 1000;
      var shake= 3;
      var vibrateIndex = 0;
      var selector = $('aside.featured a'); /* Your own container ID*/
        $(selector).click( /* The button ID */

        function(){ 

        vibrateIndex = setInterval(vibrate, interval);
        setTimeout(stopVibration, duration);

        });

        var vibrate = function(){
        $(selector).stop(true,false)
        .css({position: 'relative', 
        left: Math.round(Math.random() * shake) - ((shake + 1) / 2) +'px', 
        top: Math.round(Math.random() * shake) - ((shake + 1) / 2) +'px'
        });
        }

        var stopVibration = function() {
        clearInterval(vibrateIndex);
        $(selector).stop(true,false)
                .css({position: 'static', left: '0px', top: '0px'});
            };

        });
  • 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-04T04:09:45+00:00Added an answer on June 4, 2026 at 4:09 am

    Try this way:-

    $(function() {
      var interval = 10;
      var duration= 1000;
      var shake= 3;
      var vibrateIndex = 0;
      var selector = $('.box'); /* Your own container ID*/
        $(selector).hover( /* The button ID */
            function(){ 
            vibrateIndex = setInterval(vibrate, interval);    
            },
            function(){ 
                clearInterval(vibrateIndex);
                $(selector).stop(true,false)
                    .css({position: 'static', left: '0px', top: '0px'});
            }
        );
    
        var vibrate = function(){
            $(selector).stop(true,false)
            .css({position: 'relative', 
            left: Math.round(Math.random() * shake) - ((shake + 1) / 2) +'px', 
            top: Math.round(Math.random() * shake) - ((shake + 1) / 2) +'px'
            });
        }
    });
    

    Refer this DEMO

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

Sidebar

Related Questions

I'm attempting to make the switch from Windows to ubuntu (am using 12.04 LTS)
I am attempting to write some jQuery code that will expand a paragraph when
I've been attempting to make a folder for each architecture my code can support.
I'm attempting to make an Odata post using odata4j. After dumping the posted xml
I am attempting to make a Facebook application with node.js, however I'm having trouble
So I'm attempting to make an li element into a clickable link by absolutely
While attempting to make a game using Canvas I noticed a few quirks on
I'm attempting to make a simple query library and I'm using PDO for database
I am attempting to make the following call, PID = pthread_create(&t, NULL, schedule_sync(sch,t1), NULL);
I am attempting to make some reports in Excel using a pivot table of

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.