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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:10:55+00:00 2026-06-11T00:10:55+00:00

I feel like this is a stupid simple question, but I’ve been doing so

  • 0

I feel like this is a stupid simple question, but I’ve been doing so much CSS work lately that I feel a little rusty. So, I have several buttons with classname: and class: attributes. Basically, all I want to do is take the value of the classname attribute and append it to class. Only the buttons with className need their content appended.

classname="blah_btn blah_btnGrey" class="blah blah blah foo foo"

Would I write something like:

if ($('#ui-button').has("className")) {
$(("className").val()).appendTo("class");

or something more along the lines of:

$("button").each(function() {
//do stuff

});

Or am I in the completely wrong ballpark? Once again, any help is greatly appreciated.

  • 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-11T00:10:56+00:00Added an answer on June 11, 2026 at 12:10 am

    First off, please don’t use an attribute call className. That is reserved as the way to address the class attribute because class is a reserved word in javascript. So, if you use attributes with names of class and className, you could end up having a hard time reaching them individually in javascript. It could be a mess. Pick a more unique name for the one that isn’t actually class.

    To add the class attribute, you would just use .addClass():

    $('#ui-button').addClass("blah_btn")
    

    jQuery’s `addClass() is smart enough to not add it if it’s already present.


    If you want to get an attribute and add it to the actual class, you can do this:

    $('#ui-button').addClass($(elem).attr("myAttribute"));
    

    If you just want to add one attribute onto another, you can do this:

    var target = $('#ui-button');
    target.attr(target.attr("myAttribute") + $(elem).attr("myAttribute"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I feel like this is a really stupid question, but I've been trying
I feel like this is a stupid question, but I can't think of a
I feel like this is a stupid question, but I'm following the tutorial for
I feel really stupid for asking a question like this, but I cannot seem
I feel like this is probably a stupid question... but anyway I have this
i feel like this is a stupid question but i can't find anything anywhere.
I feel like this might be really simple but I'm just not getting it
I feel like this must have been asked before, but I've looked at Knockout
This may seem like a basic/stupid/obviously-answered question, but I wanted to check: why use
This may be a very stupid question and it's making feel like my brain

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.