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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

嘗試用函數(shù)調(diào)用的方法,但是p元素創(chuàng)建不出來?

嘗試用函數(shù)調(diào)用的方法,但是p元素創(chuàng)建不出來?

<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>無標(biāo)題文檔</title>
<style?type="text/css">
.message{????
width:200px;
height:100px;
background-color:#ccc;
????}
</style>
</head>
<body>
<script?type="text/javascript">
var?main=document.body;
function?createa(classn,aa){
????var?x=document.createElement("p");
????x.setAttribute(class,classn);
????var?y=document.createTextNode(aa);
????main.appendChild(x);
????x.appendChild(y);
}
main.createa("message","I?love?javascript");
</script>?
</body>
</html>


正在回答

1 回答

思路是對(duì)的,但是有兩個(gè)小錯(cuò)誤:
<script?type="text/javascript">
var?main=document.body;
function?createa(classn,aa){
????var?x=document.createElement("p");
????x.setAttribute("class",classn);??//第一個(gè)錯(cuò)誤:setAttribute使用時(shí)括號(hào)中的屬性class要用引號(hào)!
????var?y=document.createTextNode(aa);
????main.appendChild(x);
????x.appendChild(y);
}
createa("message","I?love?javascript");//第二個(gè)錯(cuò)誤:此處是調(diào)用函數(shù),不必再前面寫main.?!!
</script>
希望能解決你的問題!


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

胡澤涵 提問者

謝謝!
2015-08-29 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

嘗試用函數(shù)調(diào)用的方法,但是p元素創(chuàng)建不出來?

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

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

幫助反饋 APP下載

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

公眾號(hào)

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