。內容{顯示:?無;}& lt/style & gt;& lt/head & gt;& ltbody & gt& ltspan & gt設置為終點& ltdiv?class=\"content \" >1 & " />
當前位置:編程學習大全網 - 網站源碼 - 如何用html+js寫壹個div?當妳點擊這個地方的標簽時,會彈出壹個類似這樣的div。

如何用html+js寫壹個div?當妳點擊這個地方的標簽時,會彈出壹個類似這樣的div。

& lthtml & gt

& lthead & gt

& lttitle & gt& lt/title & gt;

& lt風格?type="text/css " >

。內容{顯示:?無;}

& lt/style & gt;

& lt/head & gt;

& ltbody & gt

& ltspan & gt設置為終點

& ltdiv?class="content " >1 & lt;/div & gt;

& ltdiv?class="content " >2 & lt/div & gt;

& ltdiv?class="content " >3 & lt/div & gt;

& lt腳本& gt

var?_ span = document . getelementsbytagname(" span ");

var?_ div = document . getelementsbytagname(" div ");

為了什麽?(var?我?=?0,len = _ span.length?我?& ltlen?i++)?{

_span[i]。index=_div[i]。index = I;

_span[i]。onclick=function(){

var?ind = this.index

如果?(_div[ind].className=="content ")?{

for(var?j = 0;j & ltlenj++){

_div[j]。className = " content

}

_div[ind]。className =

}否則{

_div[ind]。className = " content

}

}

};

& lt/script & gt;

& lt/body & gt;

& lt/html & gt;看看哪裏出了問題。

  • 上一篇:robot framework上傳文件的文件路徑
  • 下一篇:unityvr切換槍械的快捷鍵
  • copyright 2024編程學習大全網