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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:03:39+00:00 2026-06-14T10:03:39+00:00

I did a bit of Googling, and I found that the following code does

  • 0

I did a bit of Googling, and I found that the following code does not work because inputs[i].className is not a string. How would I make this a string??? I tried toString(). Also, inputs.length is not 0. I checked.

for (var i = 0; i < inputs.length; i++)
{
     if (inputs[i].className.indexOf("blah") == 1)
     {
      //do something
     }
}

I want to do something with only the inputs array values that have a class name of something like “blah 1;2;3;4”.

Any help would be appreciated.

  • 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-06-14T10:03:40+00:00Added an answer on June 14, 2026 at 10:03 am

    indexOf(value) returns -1 when no match, and a index starting with 0 when there is match.

    In your case, you should compare the result with 0, instead of 1.


    Note that, if you want to test if a node has some certain class name, this is not a good practice.

    A better approach is to use DOM API node.classList.contains() which is available in modern browsers.

    Or use regular expression /\bblah\b/.test(node.className) to avoid the cases that blah is a substring of another class name, say not-blah.

    Another way is to use mootools, which provides node.hasClass() to HTMLElement instances.

    Or use jQuery like $(node).hasClass().

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

Sidebar

Related Questions

I've searched quite a bit and found a few solutions that did not end
Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
Aight, did a bit of Googling and searching here, the only question I found
at work I am struggling a bit with the following situation: We have a
Interesting one this. I did do a bit Googling on the it but here
I've been googling and querying stackoverflow quite a bit but I haven't found this
I am not able to set Ajax-Solr on my system.I did a bit of
Sanity-check questions: I did a bit of googling and discovered the correct way to
I did a bit of searching and found this thread on the topic but
I did a little bit of Web Programming here and there but I never

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.