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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:03:06+00:00 2026-05-24T12:03:06+00:00

How do I change any CSS properties during runtime? Suppose I have: #mycss {

  • 0

How do I change any CSS properties during runtime?
Suppose I have:

#mycss {
   background:#000;
   padding:0;
}

Then during runtime, #mycss should be:

 #mycss {
    background:#fff;
    padding:10px;
    }

————————**EDIT***——————————————-

Im sorry guys, I’m really new to the HTML world…

My problem or question, whatever that is, I would like to create a piece of code that would change current CSS properties by simply putting a value on the input box (e.g. color: #fff or white) and when I hit the button, it would change the current CSS background color from the default color (#000) to user-defined color (e.g. #fff).

  • 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-24T12:03:06+00:00Added an answer on May 24, 2026 at 12:03 pm

    You could change it any of the following ways:

    • Adding a style declaration in the page
    • Adding an inline style declaration on the element
    • Using jQuery to change the style of the element

    Additional Style Solution:

    <style type='text/css'>
        #mycss{ background: #fff; padding: 10px; }
    </style>
    

    Inline Style Solution:

    Add the following style='background: #fff; padding: 10px' to your element with id='mycss'

    jQuery Solution (obviously requires you to include jQuery):

    $('#mycss').css('background-color','#FFFFFF').css('padding','10px');
    

    ————————————————————Edit—————————————————————–

    Using jQuery – I believe I achieved the functionality you were looking for in your edit. It could be accomplished in pure javascript as well, just let me know if you would like that solution, here is a demo.

    Type any color and change the background (Red, #F7F6F5, Purple, #999 etc.)

    //On Button Click - changes background on click...
    $('#change').click(function()
    {
        $('body').css('background-color',$('#color').val()); 
    });
    
    
    //On Textbox Change - changes background when the textbox changes...
    $('#color').change(function()
    {
             $('body').css('background-color',$(this).val());               
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi All, It's clear wehn I change any control and then posts back the
I haven't seen any docs saying jQuery can change any CSS definition such as
So I have a div and I added a background image via CSS. I
I have the following snippet that overwrites certain CSS properties:- var styleSheet = document.styleSheets[2];
I've tried the following code to change some css properties (.overthumb) of a DIV
How may I modify a XML file without any change like attributes ordering, tag
I'd like to set a connection string programmatically, with absolutely no change to any
Upon serving a request for an ASPX page, if ASP.NET notices any change to
Is there any way to change Firefox system icon (the one on the left
Is there any way to change the default tab size in a .NET RichTextBox?

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.