這段代碼為什么沒用啊
function $(id){
return typeof id==='string' ? document.getElementById(id):id;
}
window.onload=function(){
? ?//獲取鼠標(biāo)劃過或點(diǎn)擊的標(biāo)簽和內(nèi)容
? ?var title =$('notice-tit').getElementsByTagName('li');
? ?var ?content=$('notice-con').getElementsByTagName('div');
? ?if(title.length!=content.length){
? ? ? ?return;
? ? ? ?var i;
? ? ? ?for(i=o;i<title.length;i++){
? ? ? ? ? ?title[i].id=i;
? ? ? ? ? ?title.onclick(function(){
? ? ? ? ? ? ? ?alert(i);
? ? ? ? ? ?})
? ? ? ?}
? ?}
};
id不能加上去?
2017-01-09
i=o,你應(yīng)該寫成零(0),不是o。
另外,你沒有HTML+css代碼,不能幫你測試。