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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:10:03+00:00 2026-06-12T13:10:03+00:00

I have a tenuous grip on jQuery, but am trying to learn the basics

  • 0

I have a tenuous grip on jQuery, but am trying to learn the basics of adding regular Javascript to it. I want to ‘save’ a sequence of animates as a function, and then call that function via several different click events. What is the best way to go about this?

jsFiddle – http://jsfiddle.net/kfycP/1/

Simplistic Sample Code:

$(document).ready(function() {

function animateCube() {
    $('.test').fadeOut();
    $('.test').delay(500).slideDown();
}

$('.test').click(function() {
// Play "animateCube"
});

$('.link').click(function() {
// Play "animateCube"
});

});
  • 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-12T13:10:04+00:00Added an answer on June 12, 2026 at 1:10 pm

    I would assign the function to a var and reference it as the click handler for your events.

    $(document).ready(function() {
    
      var animateCube = function() {
        $('.test').fadeOut();
        $('.test').delay(500).slideDown();
      }
    
      $('.test').click(animateCube);
    
      $('.link').click(animateCube);
    
    });
    

    If you want to execute some additional code, I would wrap the handler in an anonymous function.

    $('.test').click(function(){
      // execute more code
      animateCube();
      // execute even more code
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a painfully simple blog Post creator, and I'm trying to check if the
have a nice day. I got problem when trying to create an image from
Have been trying to figure this out for an hour - and still have
Have a problem, I'm about to rebuild the search feature on my site, but
Have a photography site that I want to prevent image copying from. How can
Have been pulling out my hair trying to find out why my sessions are
Have a problem that seems easy on paper but i'm having a big problem
Have been trying to get integration testing working with my seam project and the
Have You got any examples or links to free JQuery flow diagram or network/
Have created an android test project and currently trying to write android unit tests

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.