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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:59:02+00:00 2026-05-24T08:59:02+00:00

I have a button called WatchMode. When you click this button, it will close

  • 0

I have a button called WatchMode.

When you click this button, it will close certain divs, specified by the div ID.

The javascript for this is as follows:

function watchmode() { 
document.getElementById('aps30').innerHTML = " ";
} 

Now, I want to do the same for a div that appears twice on my page, this div has a Class instead of an ID.

I tried adding this line to the javascript, but it doesn’t seem to work

document.getElementByClassName('floater').innerHTML = " ";

Any suggestions ??

  • 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-24T08:59:04+00:00Added an answer on May 24, 2026 at 8:59 am

    You have to change a number of things:

    1. Fix the spelling mistake in getElementsByClassName
    2. Treat the return results of that function call as an array
    3. Loop through the contents of the returned array in order to operate on the results
    4. Understand that not all old browsers (no version of IE before IE9) support this function so if you want to target older browsers, you may have to check for its existence and use a substitute implementation if it isn’t natively available. You can see the browser support here and see the alternate implementations in the link in Justin’s answer.

    Here’s the code:

    var divs = document.getElementsByClassName('floater');
    for (var i = 0; i < divs.length; i++) {
        divs[i].innerHTML = " ";
    }
    

    This is a place where jQuery is really useful. In jQuery, it would just be:

    $(".floater").html(" ");
    

    That would automatically find all objects with that class and set the innerHTML of all matching objects to your string.

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

Sidebar

Related Questions

I have a form with a submit button. I have called a function on
I have created a custom button called ModuleUIButton which inherits from UIButton . This
let's say that i have this button which is called Click_Here and i added
i have a button called ac and when i click on it, i want
I have an ASP.NET MVC Page with a button called Start Live Meeting. When
Assume we have a single Windows form with a button called SimpleButton1. The following
I have a WPF window, which contains a button called Cancel. Under ordinary circumstances
I have a UserControl called CustomerFinder for searhing customers. And there is "ADD" button
I have one issue with UInavigationcontroller In my firstview i have button.If i click
I have a button called Visit Website. If Visit Website is clicked then 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.