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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:14:39+00:00 2026-06-18T02:14:39+00:00

What is the difference between this code: $(‘.percentage_field’).change(function() { update_percentage(); }); $(‘.inspect1’).change(function(){ show_hide_targets(); });

  • 0

What is the difference between this code:

$('.percentage_field').change(function() {
    update_percentage();
});
$('.inspect1').change(function(){
    show_hide_targets();
});

And this code:

$('.percentage_field').change(
    update_percentage
);

$('.inspect1').change(
    show_hide_targets
);
  • 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-18T02:14:40+00:00Added an answer on June 18, 2026 at 2:14 am

    When a callback runs in response to an event, this inside the function is set to the DOM element that is the target of the event.

    In your first example, the anonymous function gets the this of the target element, but that this is not forwarded to the inner function call. Instead, the inner function runs with a this according to how it is invoked. (Here, it’s a direct “raw” call (i.e., not called as a member function), so it runs with a this equal to window, in non-script mode.)

    In your second example, the functions update_percentage and show_hide_targets get the this of the target element directly.

    Consider an example:

    function sayThis() { alert(this); }
    someElem.addEventListener("click", function() { sayThis() });
    someElem.addEventListener("click", sayThis);
    someElem.addEventListener("click", function() { sayThis.call(this) });
    

    The first will alert window (or undefined in strict mode); the second will alert the element the listener fired on. The third listener uses an anonymous function, but it invokes the inner function using .call(this), which forwards the original this to the inner function.

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

Sidebar

Related Questions

Is there any essential difference between this code: ThreadStart starter = new ThreadStart(SomeMethod); starter.Invoke();
Is there any difference between doing this: $(.topHorzNavLink).click(function() { var theHoverContainer = $(#hoverContainer); var
Can anyone tell me the functional difference between this code... for (int i =
What is the difference between StaticResources and DynamicResources in WPF? EDIT : This code
What is the difference between this code var head=document.getElementsByTagName('head')[0] var script=document.createElement('script') script.setAttribute('type', 'text/javascript') script.setAttribute('src',
int i = 3; Is there any performance difference between this code: if(i ==
This code finds the difference between today and a fixed date. #!/usr/bin/perl use strict;
What is the difference between Percolate-down/Shift-down and Heapify operation? This is my Shift-down function
I have this code in JavaScript: function change() { document.getElementById(mem).className = 'gif'; } The
I'm wondering what's the difference between this code: var c = [{test: 1}]; and

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.