如何更改动态生成的DIV id的CSS?

I have a DIV containing a loader gif picture :

... some php codes to get the $pdId

... while loop to generate dynamic li's

 echo'<li><div class="loadme" id="'.$pdId.'"><img id="qtyloading" src="../../images/loading_6.gif" width="160" height="160"/></div>


 .... some other codes

 </li>';

..... end of the while loop

There is a textarea tag that will call the external js function onBlur

  .... some codes here
  echo '<textarea  rows="3" cols="30" id="<separator>'.$ud.'<separator>'.$olue.'<separator>'.$pdId.'<separator>" onBlur="yorDesc(this.id,this.value)" >'.$deomer.'</textarea><br />';

and here is the external js file

    ... some codes to get the id 
alert (gid);
document.getElementById("'+gid+'").style.display = "block";

the gid var is the ID of the loadme div, as you see I am alerting it and it showes the correct ID being parsed, and of course you have noticed that the loadme div being generated dynamically with different IDs. I supposed that I would be able to have access to each individual loader DIV by using the above mentioned javascript code, but I am not.

Could you help me to find out why? Ask me if any part of the above code or description is not clear for you I will edit it.

Appreciated.

document.getElementById(gid.toString()).style.display = "block";

This will do the trick. Or you can use (''+gid+'') if you prefer. You almost had it, just mixed too many different quotes together.

If it is id then you can use like.works well.

document.getElementById(gid).style.backgroundColor="red";

In your case need not worry about dynamically created div through PHP.

Fiddle Demo