課程
/前端開發(fā)
/JavaScript
/JavaScript進階篇
這個代碼我運行不出來 我看的別人的代碼 然而用DW都運行不出來
也不太懂?
最后一行 createa是什么意思 ?百度也沒這種用法啊?
2017-07-09
源自:JavaScript進階篇 9-16
正在回答
最后一行是你自己定義的函數(shù)名
var?main?=?document.body; //創(chuàng)建函數(shù) function?createa(url,text) ????{ ???????var?a=document.createElement('a'); ???????a.setAttribute('href',?url);? ???????a.innerHTML=text; ???????a.style.color='red'; ???????main.appendChild(a); ????} ????//?調(diào)用函數(shù)創(chuàng)建鏈接 ????createa("http://idcbgp.cn","慕課網(wǎng)");
你這里是復(fù)制粘貼過來的,你忘了刪掉上面的函數(shù),還有你在調(diào)用函數(shù)的;也用錯了,要用英文的;號。
最后一行的createa是在調(diào)用創(chuàng)建的函數(shù)createa(function后面跟的就是函數(shù)名)
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>無標(biāo)題文檔</title></head><body><script type="text/javascript">var main = document.body;//創(chuàng)建鏈接function createa(url,text)??? {?????? var a=document.createElement('a');?????? a.setAttribute('href', url); ?????? a.innerHTML=text;?????? a.style.color='red';?????? main.appendChild(a);??? }??? // 調(diào)用函數(shù)創(chuàng)建鏈接createa("http://idcbgp.cn","慕課網(wǎng)");</script> </body></html>
舉報
本課程從如何插入JS代碼開始,帶您進入網(wǎng)頁動態(tài)交互世界
2 回答哪位大神幫忙看看
4 回答各位大神幫忙看看哪里錯了!
3 回答計算不了 哪位大神幫忙看看
4 回答大神幫忙看看
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2017-07-10
最后一行是你自己定義的函數(shù)名
你這里是復(fù)制粘貼過來的,你忘了刪掉上面的函數(shù),還有你在調(diào)用函數(shù)的;也用錯了,要用英文的;號。
2017-07-10
最后一行的createa是在調(diào)用創(chuàng)建的函數(shù)createa(function后面跟的就是函數(shù)名)
2017-07-10
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標(biāo)題文檔</title>
</head>
<body>
<script type="text/javascript">
var main = document.body;
//創(chuàng)建鏈接
function createa(url,text)
??? {
?????? var a=document.createElement('a');
?????? a.setAttribute('href', url);
?????? a.innerHTML=text;
?????? a.style.color='red';
?????? main.appendChild(a);
??? }
??? // 調(diào)用函數(shù)創(chuàng)建鏈接
createa("http://idcbgp.cn","慕課網(wǎng)");
</script>
</body>
</html>