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

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

第二個重置按鈕怎么設(shè)置?按照我的代碼,第二重置沒反應(yīng)的

<!DOCTYPE HTML>

<html>

<head>

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

<title>引用JS文件</title>

<style type="text/css">

div.sj{border: 1px solid #000;padding: 10px;width:400px;height:100px;

}

?.one{

? ? ?boder:1px solid red;

? ? ?width:200px;

? ? ?height=150px;

? ? ?backgroundColor=#ccc;

? ? ?color:blue;

?}

</style>


</head>

<body>

?<p id="p1">

? ? ?什么是變量? 從字面上看,變量是可變的量;

?</p>

?<form>

? ? ?<input type="button" value="添加樣式" onclick="add() "/> &nbsp;&nbsp;

? ? ?<input type="button" value="重置" onclick="reve()"/>

? ? ?

?</form><br>

?<div class="sj">

? ? ?

?<p id="p2">

? ? ?我們可以把變量看做一個盒子,盒子用來存放物品,物品可以是衣服、玩具、水果...等。

?</p>

?

?</form></div><br>

?<form>

? ? ?<input type="button" value="改變顏色" onclick="changecolor() "/>&nbsp;

? ? ?<input type="button" value="重置" ?onclick="rev()"/>

? ? ?</form>

<script type/javascript>

? ? function add(){

? ? ? ? var p1=document.getElementById("p1")

? ? ? ? p1.style.color="red";

? ? ? ? p1.style.backgroundColor="#ccc";

? ? }

? ? function reve(){

? ? ? ? var p1=document.getElementById("p1")

? ? ? ? p1.removeAttribute('style');

? ? }

? ? function changecolor(){

? ? ? ? var p2=document.getElementById("p2");

? ? ? ? p2.className="one";

? ? }

? ?function rev(){

? ? ? ?var p2=doucument.getElementById("p2");

? ? ? ?p2.removeAttribute('style');

? ?}

</script>

---------------------------------

用 <input type="reset" value="重置";/>也是沒反應(yīng)呢、

第二個重置按鈕怎么設(shè)置有效?

正在回答

9 回答

第54行?var p2=doucument.getElementById("p2");

document拼寫錯誤~

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

Valkyrie

第55行 改為 p2.className=''; 因為你之前changecolor()時不是添加的style而是添加了一個樣式類
2016-04-05 回復(fù) 有任何疑惑可以回復(fù)我~
#2

薇薇筱 提問者

非常感謝!
2016-04-06 回復(fù) 有任何疑惑可以回復(fù)我~
#3

薇薇筱 提問者

還是不太懂 第一個p1 用removeAttribute('style')可以實現(xiàn)重置,p2 是用className=""
2016-04-06 回復(fù) 有任何疑惑可以回復(fù)我~
#4

Valkyrie 回復(fù) 薇薇筱 提問者

因為第一個p1你的樣式在add()里用style.xxx添加的,相當于給p元素添加了一個style的屬性,其實HTML結(jié)構(gòu)變?yōu)榱?lt;p id="p1" style="color:red; background:#ccc;"> 然后在reve()重置時,p1.removeAttribute('style');的作用是去掉了p1的style這個屬性。 而p2你在changecolor()時是給其增加了一個 .one 的類名,并沒有給它添加style屬性 所以在rev()方法里,你去掉style屬性是沒有意義的,應(yīng)該將 .one 這個css類去掉
2016-04-06 回復(fù) 有任何疑惑可以回復(fù)我~
#5

薇薇筱 提問者 回復(fù) Valkyrie

好噠 O(∩_∩)O謝謝
2016-04-07 回復(fù) 有任何疑惑可以回復(fù)我~
查看3條回復(fù)

https://img1.sycdn.imooc.com//5b2b60080001c98003250142.jpg

boder應(yīng)該是border;

height=應(yīng)該是height:150px;

backgroundColor正確寫法應(yīng)該是background-color,寫在一起的是Object改變樣式寫在一起的,css樣式背景色要分開寫;

?var p2=doucument.getElementById("p2");正確拼寫應(yīng)該是document;

p2.removeAttribute('style');應(yīng)該寫成p2.className="style";

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

關(guān)于第二個重置沒有作用,和我犯了一樣的錯誤,轉(zhuǎn)答案“

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

修改:

mychar.removeAttribute("class");


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

你的代碼 錯誤的地方好多,都是些單詞拼錯了。比如說.one樣式里面的 border ?還有background-color。Java script里面調(diào)用屬性的拼寫方式和css里面是不一樣的,注意哦

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

document.拼錯


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

document.拼錯


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

p2.className='';

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

function rev(){

? ? ? ?var p2=doucument.getElementById("p2");

? ? ? ?p2.removeAttribute('style');

? ?}

這個doucment寫錯單詞啦

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

http://img1.sycdn.imooc.com//570388940001c15a05080292.jpg請檢查拼寫

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

舉報

0/150
提交
取消

第二個重置按鈕怎么設(shè)置?按照我的代碼,第二重置沒反應(yīng)的

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

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

幫助反饋 APP下載

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

公眾號

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