第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

為什么我用removeAttribute("style")來恢復(fù)樣式不行呢,

<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">

<title>讓我們互動下</title>

<style type="text/css">

P{

border:1px solid red;

background:gray;

width:100px;

height:30px;

text-align:center;

line-height:30px;

}

.one{

? border:2px solid blue;

? background:yellow;

? width:200px;

? height:50px;

? line-height:50px;

}

.two{

border:3px dashed yellow;

background:purple;

width:300px;

height:300px;

line-height:300px;

}

</style>

<script type="text/javascript">


function rec(){

var message=confirm("關(guān)注JS進(jìn)階篇");

if (message==true)?

{

document.write("希望你學(xué)有所成");

}?

else?

{

document.write("希望你能關(guān)注一下");

}

}

</script>

</head>

<body>

<p id="con">JS進(jìn)階篇</p>

<form>

<input type="button" name="button" onclick="rec()" value="點(diǎn)擊我試試" />

<input type="button" onclick="add()" value="增加樣式" />

<input type="button" onclick="change()" value="改變樣式" />

<input type="button" name="button" onclick="resetcss()" value="重置樣式" />

</form>

<script type="text/javascript">

var mychar=document.getElementById("con");

function add(){

mychar.className="one";

}

function change(){

mychar.className="two";

}

function resetcss(){


var message1=confirm("確定要恢復(fù)原始設(shè)置?");

if (message1==true)?

{


mychar.removeAttribute("style");

}?

}

</script>

</body>

</html>


正在回答

5 回答

mychar.removeAttribute("style");//這里移除的style是節(jié)點(diǎn)里面聲明的style,而不能移除className所帶來的css樣式,假如<p id="con" style=“color:red;”>JS進(jìn)階篇</p> 那么按了重置,red就會沒有。

修改:

mychar.removeAttribute("class");

4 回復(fù) 有任何疑惑可以回復(fù)我~
#1

大塊吃肉188 提問者

非常感謝!
2016-12-18 回復(fù) 有任何疑惑可以回復(fù)我~

? ? //mychar.removeAttribute("class");

? ? mychar.classList.remove("one"&&"two");

這兩句都可以的

0 回復(fù) 有任何疑惑可以回復(fù)我~

style用單引號試試

0 回復(fù) 有任何疑惑可以回復(fù)我~

你把 if else 語句補(bǔ)完整試試?

0 回復(fù) 有任何疑惑可以回復(fù)我~

你吧style煥成單引號試試 ?''

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

為什么我用removeAttribute("style")來恢復(fù)樣式不行呢,

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號