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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:12:28+00:00 2026-05-13T09:12:28+00:00

While developing a design using jQuery I stumbled across a problem. How would I

  • 0

While developing a design using jQuery I stumbled across a problem. How would I know, without having to look through the javascript, if jQuery isn’t doing a selector on a class in my HTML? That is to say, if I wanted to change the class to something else, I have no way of knowing if that class is being used elsewhere so it makes it difficult for me to easily update the design.

So, my thought was to duplicate a class name and append text (say, “-jquery”) to the end of it if it is being utilized. This way, if I wanted to change the design in the future I could do so freely, and I would instantly know what elements on the page are being used in my javascript.

For example, let’s say I have a simple div with a class:

<div class="header">This is a test</div>

And javascript that does something to the div:

$(".header").click(function() { 
     $(this).slideUp();
});

My idea is to change it to this:

<div class="header header-jquery">This is a test</div>

$(".header-jquery").click(function() { 
     $(this).slideUp();
});

Thereby separating my CSS and jQuery classes, making it easier to identify elements being used by jQuery, and allowing me to update the class if need be without affecting my javascript. Sure, the code looks a bit messier, but I don’t mind.

The questions:

  1. Is this a common practice at all?
  2. Should I do this?
  3. Is there a better way of achieving what I want?

EDIT:

One last question:

  1. Is there, perhaps, a plugin for Visual Studio that may do this for me? That is, if it notices me editing the class of an element that is being used in jQuery, it would warn me? Or perhaps even color-codes the class name to let me know it’s being used. A feature like this in the IDE would be killer…

Bara

  • 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-13T09:12:29+00:00Added an answer on May 13, 2026 at 9:12 am

    I get what you are saying and what you want to help with. Basically, you want to want add a class to the raw HTML (not dynamically) so you know if you ever go to change it in the future, that it is in use by jQuery.

    1. Is this a common practice at all?

    No, or at least not that I have seen. It seems like it would only clutter your code.

    Update: However, as you brought up in the comments, in an environment where your HTML coder doesn’t work with jQuery, it would alert them that they could break it when they edit that class. Truth be told however, as with most jQuery code, if he touches any HTML inside that element he risks breaking the code, not just the class.

    2. Should I do this?

    I personally would not. If anything, you could add a rel tag since its valid on any element:

    <div class="header" rel="jquery"></div>
    

    But even that is an “incorrect use” of a the rel attribute.

    3. Is there a better way of achieving what I want?

    Yes! At the top of your main JavaScript file for the web project put this:

    /************ Classes and Selectors In Use **************
    
       .header
       form .special
       #footer p
    
    *********************************************************/
    

    When you go to change an element, just quickly scan the top of that file. Furthermore, if you are minifying your JS for production (which you should be doing) all that will be removed so it doesn’t increase file size.

    The right way?

    Probably the best way that does take extra work, but not all the record keeping of my suggested solution, is to do automated tests. So, if you accidentally change a class, when you run your tests they will fail where they passed before.

    You can read about it here: Automated Unit Testing with JavaScript <– I personally think the answer below the accepted answer has more to offer

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

Sidebar

Ask A Question

Stats

  • Questions 354k
  • Answers 354k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just copying my answer to the same question on wix-users… May 14, 2026 at 8:25 am
  • Editorial Team
    Editorial Team added an answer After a little more experimentation it seems that jCarousel Lite… May 14, 2026 at 8:25 am
  • Editorial Team
    Editorial Team added an answer Actually, you can specify the options dynamic-update and dynamic-insert in… May 14, 2026 at 8:25 am

Related Questions

I'm looking for feedback on what other people use on their ASP.NET projects to
I am developing a medium size program in python spread across 5 modules. The
While developing AJAX program, I met the design decision to make string I18N in
I'm developing a web application for a new service, starting from Firefox 3.5. The
I am developing a web application that can support threaded comments. I need the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.