阅读:5628回复:2
求助,这段JS里的代码怎么写成W3C标准!
function text_switch(){
document.getElementById("roll_layer3").innerHTML=hot_price[cur].innerHTML; if (++cur==hot_price.length){ cur=0; } document.getElementById("roll_layer3").innerHTML+=hot_price[cur].innerHTML; } 错误都是在红色的字段里,一个是不符合W3C吧——也就是说,前面的document.getElementById("roll_layer3").innerHTML是对的,可是hot_price[cur].innerHTML我就不知道怎么写成W3C标准的代码了; 其中hot_price是某个div的id名称,导致出现第二个提示错误是说hot_price[cur]没有被定义呢——到底该如何该修改编写呢 |
|
1楼#
发布于:2008-12-29 21:21
|
|
2楼#
发布于:2008-12-29 21:21
1、id=hot_price后面加上name=hot_price;
2、代码改为 function text_switch(){ document.getElementById("roll_layer3").innerHTML=document.getElementsByName("hot_price")[cur].innerHTML; if (++cur==document.getElementsByName("hot_price").length){ cur=0; } document.getElementById("roll_layer3").innerHTML+=document.getElementsByName("hot_price")[cur].innerHTML; } 3、因为firefox则返回的是name= hot_price的object的数组。 |
|