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)';
} 

```
In order to add CSS to dynamic div you can use the following syntax

```
$("div"+dynamic_id).css({"color":"rgb(255, 125, 115)"});

```