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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:08:49+00:00 2026-05-26T11:08:49+00:00

Attempting a dynamic style change below, but the function falls silent. I’ve used JSHint,

  • 0

Attempting a dynamic style change below, but the function falls silent. I’ve used JSHint, and all seems fine.

function styleInput(elClass,color)
{
  "use strict";

  var document;
  elClass = document.getElementsByClassName(elClass);



var len = elClass.length;

    for (var i=0; i < len;i++) {

        if (elClass[i].className === elClass) 


                {

                  var tmp = elClass[i];


                  tmp.style.backgroundColor = color;

                  tmp = " ";





                }

        }




}

styleInput("fm_bushido", "#f3f3f3");

—–HTML—–

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }
</style>
</head>
<body>
  <input type="text" name="name" class="fm_bushido txt" placeholder="Name:"></input>
</body>
</html>
  • 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-26T11:08:50+00:00Added an answer on May 26, 2026 at 11:08 am

    You’re using the variable elClass twice and overwriting the value passed into the function with that returned from document.getElementsByClassName(elClass);. Once your script gets down to if (elClass[i].className === elClass), you’re comparing the classname of the element with the element itself, not the value you passed into the function (fm_bushido).

    Just change one of those elements’ names and it should work.

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

Sidebar

Related Questions

I am attempting to write a dynamic dispatcher for a function that's templated on
After attempting to install Ogre3d from source for Linux, it all built properly but
I have a web form that I am attempting to implement dynamic drop down
I'm attempting to perform dynamic sorting of data that I'm putting into grids into
I'm attempting to write a Python wrapper for poker-eval, a C static library. All
I'm building an MVC3 app for my dynamic web class, and while attempting to
As I was attempting to create a Dynamic Web Project in eclipse I received
I'm attempting to get over the hurdle of dynamic form fields in Rails --
I am attempting to make a dynamic image with PHP, and I can't find
I am attempting to implement a WPF ViewModel using Castle Windsor Dynamic Proxies. The

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.