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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:45:22+00:00 2026-05-23T12:45:22+00:00

In jQuery we can do like… $(‘.button’).click( function() { $(this).hide(); } ); But we

  • 0

In jQuery we can do like…

$('.button').click( function() {

    $(this).hide();

} );

But we can do like this too, of course:

$('.button').click( function() {

    $('.button').hide();

} );

What’re advantages of using this? Isn’t that slower?

I think the answer for this question will be something like…

There are situations when only way is to use this.

Show me example of that situation then! 🙂

Which should I use primary (if both would work)?

  • 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-05-23T12:45:23+00:00Added an answer on May 23, 2026 at 12:45 pm
    • You should use this if all you want to do is accessing DOM properties (that are implemented by all browsers, there are some).

      For example: this.href (<a>), this.src (<img>), this.id (all elements (if set)), etc.
      This is the fastet way as you don’t make a function call to jQuery.

    • You should use $(this) if you want to apply jQuery functions to the DOM element.

    • You should avoid using $(selector) if you already have a reference to that element. Searching the DOM again is way slower.

    You can see in line 92 of the source code that there is not much happening when you pass an HTML element.


    Also note that $(this).hide() and $('.button').hide(); are not equivalent. The first will only hide the clicked element, while the second will hide all .button elements.

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

Sidebar

Related Questions

I can bind a jquery event to this element like: <script type=text/javascript> $('#new_key').ready(function() {
in jQuery you can write something like $(selector).bind('click', function(e) { // something was true
I would like to know if I can use the following JQuery function on
It doesn't look like basic javascript but nor can I use JQuery commands like
In jQuery you can select two elements by id like: $('#elem, #elem2'); BUT What
Can you do this, like you can with MooTools http://ryanflorence.com/slideshow/#navigation-demo in jQuery? So you
with jquery,how can i do something just after the dom loaded,i write like this:
JS library like JQuery can be linked directly from other site (e.g. google). Usually
I would like to know if I can include some Jquery inside another JQuery
I would like to know how can I use jQuery to select multiple items

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.