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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:33:26+00:00 2026-06-13T21:33:26+00:00

This JavaScript code is to change the background of a div if the content

  • 0

This JavaScript code is to change the background of a div if the content is different:

function myfunction() {
    $a = document.getElementById('t').getElementsByTagName('div');
    var x = 0;
    while(x < $a.length) {
        var b = ($a[x].innerHTML);
        b.toString;
        alert(x + b[x]);
        if(b == 'PENDING SELECTING TEAM MEMBER' ||b == 'PENDING APPROVAL BY SCHEME MANAGER' ||b == 'PENDING SELECTING TEAM MEMBER' ||b == 'PENDING REVIEW TEAM MEMBER BY LEAD ASSESSOR' ||b == 'PENDING ACKNOWLEDGEMENT BY TA/LA' ||b == 'PENDING PREPARE AUDIT PLAN BY LA' ||b == 'PENDING REVIEW AUDIT PLAN BY AO' ||b == 'PENDING ACCEPT LA BY LAB' ||b == 'PENDING VERIFY REASON BY AO' ||b == 'PENDING CONDUCT ASSESSMENT' || b == 'PENDING CORRECTIVE ACTION BY CAB' || b == 'PENDING REVIEW BY AO' || b == 'PENDING CORRECTIVE ACTION APPROVAL BY SCHEME MANAGER' ||b == 'PENDING APPROVAL BY DOA' ){
            document.getElementById('status'+x).style.background="maroon";
            alert(x + b);
        }
        x++;

    }
}

It doesn’t work because the if statement is failing.

Can someone help me figure out what’s wrong?

  • 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-13T21:33:28+00:00Added an answer on June 13, 2026 at 9:33 pm

    Just as a note, b.toString; should be b.toString();

    And personally I prefer using double quotes, but that’s just due to being used to strongly type them and having a difference between characters and Strings.

    Saw others say it, but just to emphasize : a variable in a function not having the ‘var’ keyword makes them global, meaning they are accessible, and changeable in any scope in the program.

    Try using the following javascript code : JSFiddle

    Changed the way you set the background colour.

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

Sidebar

Related Questions

This is my JavaScript code: <script> function change(name){ var element = document.all.name.value; } </script>
This Javascript code is using the 'this' keyword inside a nested function (which is
I have this JavaScript code: for (var idx in data) { var row =
How to write this JavaScript code without eval? var typeOfString = eval(typeof + that.modules[modName].varName);
I have the following code : <div id=wrapper> <div style=width:500px;background-color:yellow;> // this is a
This javascript code does not work in IE8, but works in Firefox and Google
Given this JavaScript code (which is just a comment referring to a url): //
I have this Javascript code I inherited from another developer. I am very new
i have this javascript code to which i want to add the jquery fade-in
I have this javascript code below that uses jquery, it is suppoed to be

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.