24th
03.08
document.getElementById使用方法1
我想把one1拆开1这个在子程序里传递过去。后跟one组合在一起。做id。
这样给 id 为 one1 的对象加样式。
(”one”+a).style.background=”#f00″;这种写法不对。现用到了
document.getElementById
看下面试例:
- <script type="text/javascript">
- function sub(a){
- document.getElementById("one"+a).style.background="#f00";
- }
- </script>
- <div id="one1" style="background:#ccc; width:100px; height:100px;" onclick="return sub('1')"></div>
Name: Cngothic 












