document.getElementById使用方法1
我想把one1拆开1这个在子程序里传递过去。后跟one组合在一起。做id。
这样给 id 为 one1 的对象加样式。
(”one”+a).style.background=”#f00″;这种写法不对。现用到了
document.getElementById
看下面试例:

  1. <script type="text/javascript">
  2.  function sub(a){
  3.  document.getElementById("one"+a).style.background="#f00";
  4.  }
  5. </script>
  6. <div id="one1" style="background:#ccc; width:100px; height:100px;" onclick="return sub('1')"></div>

,