Question: I want to apply css to dynamic div id.

```
var status = var status = item.down().next().innerHtml();
if(status == "test")
{  
    var c = 'item_'+i ;
    c.style.backgroundColor = 'rgb(255, 125, 115)';
    //'item'+ i.style.backgroundColor = 'rgb(255, 125, 115)';
}  

```

here "item\_" + i is a dynamic Ids of every rows.like item\_1,item\_2,item\_3 etc. So I want to add css in some of the rows. ie . item\_1 and item\_3 or else.

So how can this possible.

Answer: 
You are trying to apply the style property to string instead you need to get the element by `id`. Use **[`documet.getElementById()`](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById)** for that

```
var status = var status = item.down().next().innerHtml();
if(status == "test")
{  
    var c = 'item_'+i ;
    document.getElementById(c).style.backgroundColor = 'rgb(255, 125, 115)';
    //'item'+ i.style.backgroundColor = 'rgb(255, 125, 115)';
} 

```

Or use jQuery **[id-selector](https://api.jquery.com/id-selector/)** and for applying css use **[`css()`](https://api.jquery.com/css/)**

```
var status = var status = item.down().next().innerHtml();
if(status == "test")
{  
    var c = 'item_'+i ;
    $('#'+c).css('background-color','rgb(255, 125, 115)');
    //'item'+ i.style.backgroundColor = 'rgb(255, 125, 115)';
} 

```
You can use as mentioned other users, or you can also use the below,
basically if you use pure JavaScript then you have to identify the element first by using the function `document.getElementbyId`

```
var c = document.getElementbyId('item_' + i);
c.style.backgroundColor = 'rgb(255, 125, 115)';

```