課程
/前端開發(fā)
/JavaScript
/JavaScript進(jìn)階篇
是否可以設(shè)置間隔時(shí)間,如3秒,選項(xiàng)卡自動(dòng)切換。
函數(shù)應(yīng)該如何改動(dòng)?
2016-07-12
源自:JavaScript進(jìn)階篇 10-1
正在回答
function f1(){??????? //只是為了改變點(diǎn)擊后的樣式,重復(fù)代碼很多,造成重復(fù)勞動(dòng),后期可調(diào)整成循環(huán)??????? document.getElementById("first").style.display="block";??????? document.getElementById("second").style.display="none";??????? document.getElementById("third").style.display="none";??????? document.getElementById("tag1").style.borderTopColor="red";??????? document.getElementById("tag1").style.borderTopWidth="2px";??????? document.getElementById("tag1").style.borderBottomWidth="2px";??????? document.getElementById("tag2").style.borderTopColor="blue";??????? document.getElementById("tag2").style.borderTopWidth="1px";??????? document.getElementById("tag2").style.borderBottomWidth="1px";??????? document.getElementById("tag3").style.borderTopColor="blue";??????? document.getElementById("tag3").style.borderTopWidth="1px";??????? document.getElementById("tag3").style.borderBottomWidth="1px";??? }??? function f2(){??????? document.getElementById("first").style.display="none";??????? document.getElementById("second").style.display="block";??????? document.getElementById("third").style.display="none";??????? document.getElementById("tag1").style.borderTopColor="blue";??????? document.getElementById("tag1").style.borderTopWidth="1px";??????? document.getElementById("tag1").style.borderBottomWidth="1px";??????? document.getElementById("tag2").style.borderTopColor="red";??????? document.getElementById("tag2").style.borderTopWidth="2px";??????? document.getElementById("tag2").style.borderBottomWidth="2px";??????? document.getElementById("tag3").style.borderTopColor="blue";??????? document.getElementById("tag3").style.borderTopWidth="1px";??????? document.getElementById("tag3").style.borderBottomWidth="1px";??? }??? function f3(){??????? document.getElementById("first").style.display="none";??????? document.getElementById("second").style.display="none";??????? document.getElementById("third").style.display="block";??????? document.getElementById("tag1").style.borderTopColor="blue";??????? document.getElementById("tag1").style.borderTopWidth="1px";??????? document.getElementById("tag1").style.borderBottomWidth="1px";??????? document.getElementById("tag2").style.borderTopColor="blue";??????? document.getElementById("tag2").style.borderTopWidth="1px";??????? document.getElementById("tag2").style.borderBottomWidth="1px";??????? document.getElementById("tag3").style.borderTopColor="red";??????? document.getElementById("tag3").style.borderTopWidth="2px";??????? document.getElementById("tag3").style.borderBottomWidth="2px";??? }
這個(gè)比較通俗,你可以換成循環(huán),代碼就比較簡單
舉報(bào)
本課程從如何插入JS代碼開始,帶您進(jìn)入網(wǎng)頁動(dòng)態(tài)交互世界
3 回答實(shí)現(xiàn)選項(xiàng)卡切換的效果
1 回答js 實(shí)現(xiàn)選項(xiàng)卡切換
3 回答怎么實(shí)現(xiàn)選項(xiàng)卡切換的
1 回答選項(xiàng)卡的切換怎么實(shí)現(xiàn)不了?
3 回答選項(xiàng)卡切換不能實(shí)現(xiàn),怎么回事啊
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-07-12
function f1(){
??????? //只是為了改變點(diǎn)擊后的樣式,重復(fù)代碼很多,造成重復(fù)勞動(dòng),后期可調(diào)整成循環(huán)
??????? document.getElementById("first").style.display="block";
??????? document.getElementById("second").style.display="none";
??????? document.getElementById("third").style.display="none";
??????? document.getElementById("tag1").style.borderTopColor="red";
??????? document.getElementById("tag1").style.borderTopWidth="2px";
??????? document.getElementById("tag1").style.borderBottomWidth="2px";
??????? document.getElementById("tag2").style.borderTopColor="blue";
??????? document.getElementById("tag2").style.borderTopWidth="1px";
??????? document.getElementById("tag2").style.borderBottomWidth="1px";
??????? document.getElementById("tag3").style.borderTopColor="blue";
??????? document.getElementById("tag3").style.borderTopWidth="1px";
??????? document.getElementById("tag3").style.borderBottomWidth="1px";
??? }
??? function f2(){
??????? document.getElementById("first").style.display="none";
??????? document.getElementById("second").style.display="block";
??????? document.getElementById("third").style.display="none";
??????? document.getElementById("tag1").style.borderTopColor="blue";
??????? document.getElementById("tag1").style.borderTopWidth="1px";
??????? document.getElementById("tag1").style.borderBottomWidth="1px";
??????? document.getElementById("tag2").style.borderTopColor="red";
??????? document.getElementById("tag2").style.borderTopWidth="2px";
??????? document.getElementById("tag2").style.borderBottomWidth="2px";
??????? document.getElementById("tag3").style.borderTopColor="blue";
??????? document.getElementById("tag3").style.borderTopWidth="1px";
??????? document.getElementById("tag3").style.borderBottomWidth="1px";
??? }
??? function f3(){
??????? document.getElementById("first").style.display="none";
??????? document.getElementById("second").style.display="none";
??????? document.getElementById("third").style.display="block";
??????? document.getElementById("tag1").style.borderTopColor="blue";
??????? document.getElementById("tag1").style.borderTopWidth="1px";
??????? document.getElementById("tag1").style.borderBottomWidth="1px";
??????? document.getElementById("tag2").style.borderTopColor="blue";
??????? document.getElementById("tag2").style.borderTopWidth="1px";
??????? document.getElementById("tag2").style.borderBottomWidth="1px";
??????? document.getElementById("tag3").style.borderTopColor="red";
??????? document.getElementById("tag3").style.borderTopWidth="2px";
??????? document.getElementById("tag3").style.borderBottomWidth="2px";
??? }
這個(gè)比較通俗,你可以換成循環(huán),代碼就比較簡單