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

  • Home
  • SEARCH
  • 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 8365821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:45:15+00:00 2026-06-09T12:45:15+00:00

I am used to using this syntax : <script type=text/javascript> $(document).ready(function(){ $(button).click(function(){ $(p).hide(1000,function(){ alert(The

  • 0

I am used to using this syntax :

<script type="text/javascript">
   $(document).ready(function(){
      $("button").click(function(){
           $("p").hide(1000,function(){
               alert("The paragraph is now hidden");
           });
      });
   });
</script>

but just lately I came across this one which works as well,

<script type="text/javascript">
    $(document).ready(function(){
        $("a").hover(function(){
            $(this).stop().animate({ color: '#a6d13b'}, "normal");
        }, function() {
            $(this).stop().animate({ color: '#000000'}, "normal"); //original color
        });
    });
</script>

I’m just new to jquery and would really appreciate some help. why does the second syntax work ? even though its outside the animate function. ?

  • 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-09T12:45:17+00:00Added an answer on June 9, 2026 at 12:45 pm

    The two scripts are doing completely different things, but (just guessing here) I think what is confusing you is that in the second script the .hover() function takes two callbacks as parameters, one for mouseenter and one for mouseleave, like this:

    $("a").hover(callbackFunctionOne, callbackFunction2);
    // OR
    $("a").hover(function() { ... }, function() { ... });
    

    In your example it is within these two functions passed to .hover() that the .animate() calls occur, but the .animate() calls themselves don’t (in this case) have callbacks.

    EDIT: Now that dknaack has edited your code to indent it properly it is more obvious that the .animate() calls are inside the two functions. When it wasn’t indented it was much harder to see what belonged to what.

    Note that .animate() (and many, many other jQuery functions) can take a callback, but this is optional.

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

Sidebar

Related Questions

I've seen a few examples of people using this syntax for HTML.BeginForm: (Html.BeginForm<Type>(action =>
I came across this code in a website I am maintaining: <script type=text/html id=searchList>
I am using this piece of code (the port used is 995) : Private
I've got 3 connectionstrings in web.config, and I used theirs like this: using (SqlConnection
I used this link to create a SHA1 hash for any data using C++.
I used this tutorial to rename a view controller http://iosdeveloperzone.com/2011/05/14/how-to-rename-a-class-using-refactoring-in-xcode-4/ Basically just switch to
I used this example (http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/) to upload file from android device to server, it
This is how I used to make method calls: SvcHelper.Using<SomeWebServiceClient>(proxy => { proxy.SomeMethod(); }
I've used this example to to implement some sort of guestbook, only I'm using
below is the code i'm using and i've used this 100x's before. And now

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.