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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:09:20+00:00 2026-06-09T07:09:20+00:00

This is more of an organisation question concerning Jquery. Using the following simple example:

  • 0

This is more of an organisation question concerning Jquery.

Using the following simple example:

<a href="#" class="click">click me</a>

<script>
$(document).ready(function(){
    $('.click').on('click',function(){
          alert('Clicked!');
    });
});
</script>

Now multiply this by a 1000 on your website, it can quickly get messy. You also can forget which classes you attributed for Jquery or for your CSS.
I usually try to avoid mixing both, so I add my classes for CSS and others for the Jquery, in case I change I the layout or use that section somewhere else, … I can change the CSS. But how to do you remember which one is for CSS or Jquery? Do you name your classes “JSclassName” or something like that?

Let me know if I’m not clear and thanks for your help.

  • 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-09T07:09:23+00:00Added an answer on June 9, 2026 at 7:09 am
    • Have a consistent naming scheme for your “sections” in terms of case and meaning
    • Keep id and class names the same both for CSS and JS to avoid the confusion.
    • Relating to semantic code, you should give meaning to the class/id names as well. This helps you remember what you are adding code for. Don’t use something like “centeredContainer” or “thisIsClickable“.

    Example:

    <section class="weatherWidget">
        <ul class="forecast">
            <li class="vicinity">
               ...
        <ul class="news">
            <li class="region">
               ...
    

    I also namespace my CSS and JS to avoid conflicts. The following code ensures that only weather widget contents are referenced by the code:

    //this click event is only for weatherWidget vicinity
    $('.weatherWidget .vicinity').on('click',function{...});
    
    //this CSS is only for weatherWidget regions
    .weatherWidget .region{...}
    

    Also, although I don’t really use them nor endorse using them, LESS and SASS frameworks can also help in terms of avoiding redundant CSS code by using variables.

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

Sidebar

Related Questions

This is more of a design question. I have a template class, and I
Ok, I'm going to try to make this more clear because my last question
This is more of a hypothetical question. I am wondering if anyone knows if/how
Consider the following code: <html> <head></head> <body> <div id='test' class='blah'> <a href='http://somesite.com/' id='someLink'>click!</a> </div>
I wish that I had a more precisely descriptive title for this question, but
Apologies if this is a simple question, I'm still pretty new to this, but
This is not really a technical programming question, but has more to do with
This is more of a generic question. But I am trying to understand a
I have 2 django models like this: class UserProfile(models.Model): user = models.OneToOneField(User) organisation =
I want to know this more in detail. Is it a realtime scheduler? An

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.