課程
/前端開(kāi)發(fā)
/JavaScript
/JavaScript入門(mén)篇
若是要復(fù)原該如何?
2017-08-04
源自:JavaScript入門(mén)篇 3-6
正在回答
有一個(gè)函數(shù)removeAttribute("style");可以恢復(fù)
//第一種方法;增加一個(gè)按鈕使p1其恢復(fù)外觀
<input type="button" value="恢復(fù)外觀" onclick="reset()"/>
?function reset(){
? ? ? var p1 = document.getElementById("p1");
? ? ?p1.className = "";
? }
//第二種方法:使用一個(gè)變量記錄樣式,更改時(shí)據(jù)此判斷
var p2style = 1//表示p2的當(dāng)前樣式
? function modify(){
? ? ?if(p2style == 1){
? ? ? ? var p2 = document.getElementById("p2");
? ? ? ? p2.className = "two";
? ? ? ? p2style = 2;
? ? ?}else{
? ? ? ? p2.className = "one";
? ? ? ? p2style = 1;?
? ? ?}
慕圣9424722
Realding 回復(fù) 慕圣9424722
慕圣9424722 回復(fù) Realding
設(shè)置className="";空內(nèi)容,就直接沒(méi)有樣式了,具體你是直接改代碼還是再弄個(gè)按鈕+function,都可以
舉報(bào)
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門(mén)
4 回答removeAttribute是清除所有樣式還是恢復(fù)原來(lái)的樣式
1 回答removeattribute恢復(fù)樣式?
2 回答恢復(fù)樣式代碼
4 回答怎么把在js中設(shè)置的樣式恢復(fù)原始值
6 回答恢復(fù)原始值
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-08-05
有一個(gè)函數(shù)removeAttribute("style");可以恢復(fù)
2017-08-04
//第一種方法;增加一個(gè)按鈕使p1其恢復(fù)外觀
<input type="button" value="恢復(fù)外觀" onclick="reset()"/>
?function reset(){
? ? ? var p1 = document.getElementById("p1");
? ? ?p1.className = "";
? }
//第二種方法:使用一個(gè)變量記錄樣式,更改時(shí)據(jù)此判斷
var p2style = 1//表示p2的當(dāng)前樣式
? function modify(){
? ? ?if(p2style == 1){
? ? ? ? var p2 = document.getElementById("p2");
? ? ? ? p2.className = "two";
? ? ? ? p2style = 2;
? ? ?}else{
? ? ? ? var p2 = document.getElementById("p2");
? ? ? ? p2.className = "one";
? ? ? ? p2style = 1;?
? ? ?}
? }
2017-08-04
設(shè)置className="";空內(nèi)容,就直接沒(méi)有樣式了,具體你是直接改代碼還是再弄個(gè)按鈕+function,都可以