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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:29:33+00:00 2026-05-15T06:29:33+00:00

A jQuery best practices question. I am writing a very jQuery intensive web page.

  • 0

A jQuery best practices question.

I am writing a very jQuery intensive web page. I am new to jQuery and notice its power, but as I come with heavy javascript experience and knowledge, my question is: What should be done in jQuery and what in plain javascript.

For example, there are callbacks that send a plain DOM object as an argument. Should I use that or should I wrap it ( like $(this)).

Does it matter if I do this.x=y or $(this).attr(“x”, y).

  • 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-15T06:29:34+00:00Added an answer on May 15, 2026 at 6:29 am

    If your function receives a DOM object and you don’t need any jQuery functionality for that DOM object, then there is no need to make convert it to a jQuery object. For instance, if you receive a checkbox object, you can examine the checked property without any use of jQuery.

    However, if you need to navigate to a different element from that checkbox, it might be worthwhile to convert it:

    function yourCallback(cb) {
        cb = $(cb);
        var sel = $(cb).closest('td').next().find('select');
        // For example, update the options in a neighboring select field
        ...
    }
    

    jQuery (as do other libraries) blend in smoothly with native JS. If you need extra functionality, augment the object in question.

    As for your last question: You might find the data function useful to avoid nonstandard DOM attributes. If your property x in your question is in fact a valid DOM attribute, you can write either this.x = y or $(this).attr('x', y), IMO it does not matter much. However, if x is not a DOM attribute, use

    $(this).data('key', value)
    

    That way, you can store arbitrary key-value pairs with the DOM element, where value can be an arbitrary primitive value or object.

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

Sidebar

Related Questions

I think this is just a Best Practices question, but I was wondering if
What's a jQuery like and/or best practices way of getting the original target of
I'm curious as to if there are any best practices relating to JQuery when
I have been reading Yahoo's Best Practices For Speeding Up Your Website , but
What is the best jQuery status message plugin? I like jGrowl and Purr ,
Using jQuery, what's the best way to find the next form element on the
What is the best method for removing a table row with jQuery?
What is the best way to create fluid width/height rounded corners with jQuery? That
I'm working with jQuery UI's droppables and am wondering what the best way to
What's the best way to load HTML markup for a custom jQuery UI widget?

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.