Total Page Preview:   000000000191

In jQuery, what is the difference between $(this) and this?

Difference between $(this) and this.

In jQuery, $(this) and this have different meanings and serve different purposes.
  • $(this): This is a jQuery object that refers to the current HTML element being operated on. It allows you to utilize jQuery methods and functions on the selected element.
  • this: This refers to the current HTML element in a JavaScript context. It does not have access to jQuery methods and functions unless wrapped in a jQuery object.
Here's an example to illustrate the difference:
in this example, when you click on any paragraph, the jQuery version of the code uses $(this) to hide the clicked paragraph. On the other hand, the JavaScript version of the code uses this to hide the clicked paragraph. $(this) provides access to jQuery methods, whereas this allows access to standard JavaScript properties and methods.
 
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments