How to change CSS where id=array(index)?

Tags: javascript,jquery,html,css,arrays

Problem :

i just write an small code that should change CSS of X ids.

I have 3 ids in HTML objects (every element has 1 Class)=

element 1 id = "p1" class="test1"
element 2 id = "p2" class="test1"
element 3 id = "p3" class="test1"

i create two Arrays :

 var statArray = ["p1","p3"];
 var array = ["p1","p3"];

than i check if Array 1 = Array 2

for (var ix = 0; ix < array.length; ix++) {
if (array[ix] === statArray[ix])

Now i will change the css (background-color) of the ids.

How can i change the ids where id = array[ix]?

my attempt:


Solution :

Just use this

for (var ix = 0; ix < array.length; ix++) {
    if (array[ix] === statArray[ix]){

    CSS Howto..

    Python: How to override text area in form using CSS - how does it all work together?

    how to show JS alert on open of each tab of the slider?

    How can you assign a class to an id in css or javascript?

    How to use CSS absolute position inside a scrollable div element

    How to use nth-child in CSS to select all elements after the 3rd one?

    How to fit two divs side by side horizontally?

    how should i set scrollbar properties in css

    How to avoid an hover on a menu item to affect the menu items on the right

    How can I force an outer div to expand to height of inner div?

    How to apply two CSS classes to a single div/span

    how to add several td and tr in css

    How to make an image appear over another image when mouse hovers with css3?

    How are styles within div's made 'safer' (i.e. so they do not override parent styles)

    How do I put an image on top of an image without using absolute positioning?

    On css: if text line is break show dots

    How to make elements appear under a
      in Firefox & IE8?

    CSS: How to set up border radius cross browser (only IE8 and IE9 missing ?)

    How to force div element to keep its contents inside container

    How to appy font color from li:hover to inner a link text using CSS

    CSS how to get a div to the right side and a div exactly in the middle?

    How to resize Brand Image?

    How to create a speech bubble in css?

    How to CSS: select element based on inner HTML

    Increasing font size for links on hover changes background color size, how to stop this?

    How important is it to be leaving out the last ';' inside a set of CSS rules

    CSS : how to center a input inside a div

    html/css - using sprite with tag - how to remove the outline in Chrome?

    How can I set a html web page adapt to only a tablet size or large screen in css? [closed]

    how to update a css class dynamically onclick a dropdown jquery