dshmvqnl98119 2014-01-25 17:02
浏览 101
已采纳

如何更改动态生成的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.

  • 写回答

2条回答 默认 最新

  • dtgr6303 2014-01-25 17:20
    关注
    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?