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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:09:31+00:00 2026-05-25T16:09:31+00:00

Before today I have never before used JavaScript so I’m trying to learn as

  • 0

Before today I have never before used JavaScript so I’m trying to learn as I go here.

On a webpage I want to select all html input tags with the class “exampleClass” and I want to replace the value. Can anyone show me a good/quick code snippet on how to do this or point me in the right direction to another thread or tutorial?

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-25T16:09:32+00:00Added an answer on May 25, 2026 at 4:09 pm

    Plain Javascript

    In plain javascript (no jQuery-like framework), you could do it like this:

    var list = document.getElementsByClassName('exampleClass');
    
    for (var i = 0, len = list.length; i < len; i++) {
        list[i].value = "foo";
    }
    

    But, getElementsByClassName() isn’t supported in older versions of IE (not until IE9). If you want to make the plain JS version work with older browsers, then you have to get a substitute for getElementsByClassName() for use when it isn’t supported. There are many implementations which you can find with Google. Here’s one of them: http://robertnyman.com/2008/05/27/the-ultimate-getelementsbyclassname-anno-2008/.

    jQuery

    Frameworks like jQuery are very, very useful for this kind of operation and they have better cross-browser and old-browser support. In jQuery, this operation would work pretty much everywhere and be just this one line.

    $(".exampleClass").val("foo");
    

    Sizzle

    If you want good cross-browser support, but want something lighter weight than jQuery, you can use just the Sizzle selector library (which is what is used inside of jQuery) in which case the code would be this:

    var list = Sizzle('.exampleClass');
    
    for (var i = 0, len = list.length; i < len; i++) {
        list[i].value = "foo";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never used Watin before today. I need to get a collection of
I have never used Informix before and I'm trying to write a query that
I started learning how to use Selenium today. I have never used it before.
Today I came across a new CSS syntax that I have never seen before
I encountered an interesting thing today that I have never noticed before. It appears
I am completely new to Python-- never used it before today. I am interested
I've never done this before, so im lost here. I have the following transactions
I am referred to Hudson today. I have heard about continuous integration before, but
Before you answer this I have never developed anything popular enough to attain high
Today I found out about an interface I'd never heard of before: IGrouping IEnumerable<IGrouping<YourCategory,

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.