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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:20:51+00:00 2026-05-29T07:20:51+00:00

I am working with a javascript function which takes a value from a <input

  • 0

I am working with a javascript function which takes a value from a <input type="text" /> and then write it as a text without being an input. I do this using innerHTML and it works perfectly.

My question is: How can I use a CSS class to edit the color and size of the text I am writting with innerHTML

var element = document.getElementById("element");
var value = document.getElementById("value").value;
element.innerHTML = value;

Thank You!

  • 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-29T07:20:54+00:00Added an answer on May 29, 2026 at 7:20 am

    JavaScript:

    element.className = 'foo';
    // or
    element.className += ' foo';
    

    CSS:

    .foo {
        color: #F00;
        font-size: 2em;
    }
    

    Or, more advanced: elem.classList.add( 'foo' ); (As usual, IE gets the polyfill via conditional comments.)
    – Šime Vidas

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

Sidebar

Related Questions

I tried to write a function to check key code with JavaScript. It's working
This script of mine has a function, which is not working the way, I
I have a script embedded in a page, which is as follows: <script type=text/javascript>
I'm working with some existing javascript code which takes an LI and makes it
Window.open javascript function is not working in Mozilla, but working in other browsers, here
I'm working on a JavaScript image resizing feature which rely on the IE only
I'm working on a 3D learning-based game which mainly utilizes C++ and Javascript. I'm
Being unable to locate a working php/javascript implementation of blowfish, I'm now considering using
Working on an AJAX website (HTML,CSS,JavaScript, AJAX, PHP, MySQL). I have multiple javascript functions
I need JavaScript working almost perfectly in my application that should be able to

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.