課程
/前端開發(fā)
/JavaScript
/JavaScript入門篇
........
2015-06-12
源自:JavaScript入門篇 4-1
正在回答
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?Content="text/html;?charset=utf-8"?/> <title>javascript</title> <style?type="text/css"> body{font-size:12px;} #txt{ ????height:400px; ????width:600px; ????border:#333?solid?1px; ????padding:5px;} p{ line-height:18px; text-indent:2em;} </style> </head> <body> ??<h2?id="con">JavaScript課程</H2> ??<div?id="txt"> ?????<h5>JavaScript為網頁添加動態(tài)效果并實現(xiàn)與用戶交互的功能。</h5> ????????<p>1.?JavaScript入門篇,讓不懂JS的你,快速了解JS。</p> ????????<p>2.?JavaScript進階篇,讓你掌握JS的基礎語法、函數(shù)、數(shù)組、事件、內置對象、BOM瀏覽器、DOM操作。</p> ????????<p>3.?學完以上兩門基礎課后,在深入學習JavaScript的變量作用域、事件、對象、運動、cookie、正則表達式、ajax等課程。</p> ??</div> ??<form> ??<!--當點擊相應按鈕,執(zhí)行相應操作,為按鈕添加相應事件--> ????<input?type="button"?value="改變顏色"?onClick="changeColor()"?> ????<input?type="button"?value="改變寬高"?onClick="changeWidth()"> ????<input?type="button"?value="隱藏內容"?onClick="HiddenContent()"> ????<input?type="button"?value="顯示內容"?onClick="DisplayContent()"> ????<input?type="button"?value="取消設置"?onClick="ResetDefault()"> ??</form> ??<script?type="text/javascript"> //定義"改變顏色"的函數(shù) ????function?changeColor() ????{ ????????document.getElementById("txt").style.color="red"; ????} //定義"改變寬高"的函數(shù) ????function?changeWidth() ????{ ????????document.getElementById("txt").style.width="300px"; ????????document.getElementById("txt").style.height="300px"; ????} //定義"隱藏內容"的函數(shù) ?????function?HiddenContent() ????{ ????????document.getElementById("txt").style.display="none"; ????} //定義"顯示內容"的函數(shù) ?????function?DisplayContent() ????{ ????????document.getElementById("txt").style.display="block"; ????} //定義"取消設置"的函數(shù) ?????function?ResetDefault() ????{ ????????var?reset1=confirm("是否重置所有屬性為默認值"); ????????if(reset1?==?true?) ????????{ ?????????????document.getElementById("txt").removeAttribute('style'); ????????} ????} ??</script> </body> </html>
<!DOCTYPE?HTML> <html> <head> <meta?http-equiv="Content-Type"?Content="text/html;?charset=utf-8"?/> <title>javascript</title> <style?type="text/css"> body{font-size:12px;} #txt{ ????height:400px; ????width:600px; border:#333?solid?1px; padding:5px;} p{ line-height:18px; text-indent:2em;} </style> </head> <body> ??<h2?id="con">JavaScript課程</H2> ??<div?id="txt">? ?????<h5>JavaScript為網頁添加動態(tài)效果并實現(xiàn)與用戶交互的功能。</h5> ????????<p>1.?JavaScript入門篇,讓不懂JS的你,快速了解JS。</p> ????????<p>2.?JavaScript進階篇,讓你掌握JS的基礎語法、函數(shù)、數(shù)組、事件、內置對象、BOM瀏覽器、DOM操作。</p> ????????<p>3.?學完以上兩門基礎課后,在深入學習JavaScript的變量作用域、事件、對象、運動、cookie、正則表達式、ajax等課程。</p> ??</div> ??<!--當點擊相應按鈕,執(zhí)行相應操作,為按鈕添加相應事件--> ????<input?type="button"?value="改變顏色"?onclick="b()">?? ????<input?type="button"?value="改變寬高"?onclick="g()"> ????<input?type="button"?value="隱藏內容"?onclick="c()"> ????<input?type="button"?value="顯示內容"?onclick="s()"> ????<input?type="button"?value="取消設置"?onclick="x()"> ??<script?type="text/javascript"> //定義"改變顏色"的函數(shù) function?b(){ var?obj=document.getElementById("txt"); ????obj.style.color="red"; obj.style.backgroundColor="green" } //定義"改變寬高"的函數(shù) function?g(){?? ???var?obj=document.getElementById("txt"); ????obj.style.width="700px"; ????obj.style.height="400px"; } //定義"隱藏內容"的函數(shù) function?c(){ ????????var?obj=document.getElementById("txt"); ????????obj.style.display="none"; ????} //定義"顯示內容"的函數(shù) function?s() { ????var?obj=document.getElementById("txt"); ????obj.style.display="block"; } //定義"取消設置"的函數(shù) function?x(){ ????var?obj=document.getElementById("txt"); ??????obj.style.color="#000"; ??????obj.style.backgroundColor="#fff";? ??????obj.style.width="600px"; ??????obj.style.height="400px"; ??????obj.style.display="block"; } ??</script> </body> </html>
稀碎。。。。。
你看看你后三個的事件寫成啥了,是onclick事件啊,親
<input type="button" value="改變顏色" onclick="b()"> ???? <input type="button" value="改變寬高" onclick="g()">??? <input type="button" value="隱藏內容" onclock="c()">??? <input type="button" value="顯示內容" onclock="s()">??? <input type="button" value="取消設置" onclock="x()">
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
3 回答覺得代碼沒有錯 可是運行沒反應 有同學能幫我看看嗎?
3 回答4_1編程,沒有運行出來,哪位同學能幫忙看看錯誤的地方在哪里?謝謝!錯誤已找出
1 回答大家能幫忙看看為什么我的代碼運行不起來嗎?多謝了!
1 回答求幫忙看這個代碼哪里有問題,為什么運行不了,主要是confirm這個框他就彈不出來,非常感謝。
2 回答有人能幫忙看下為什么我的代碼運行不起來嗎?多謝了!
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2015-06-12
2015-06-12
2015-06-12
稀碎。。。。。
2015-06-12
你看看你后三個的事件寫成啥了,是onclick事件啊,親
<input type="button" value="改變顏色" onclick="b()"> ?
??? <input type="button" value="改變寬高" onclick="g()">
??? <input type="button" value="隱藏內容" onclock="c()">
??? <input type="button" value="顯示內容" onclock="s()">
??? <input type="button" value="取消設置" onclock="x()">