課程
/前端開發
/JavaScript
/JavaScript入門篇
我試過很多輸入,沒有一個有用的???
2016-05-26
源自:JavaScript入門篇 4-1
正在回答
個人代碼,可以互相切磋交流?
<input type="button" onclick="cgColor()" value="改變顏色" > ?
? ? <input type="button" onclick="cgwh()" value="改變寬高" >
? ? <input type="button" onclick="hidetext()" value="隱藏內容" >
? ? <input type="button" onclick="showtext()" value="顯示內容" >
? ? <input type="button" onclick="rst()" value="取消設置" >
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數
function cgColor(){
? ? mychar = document.getElementById("txt");
? ? mychar.style.color="red";
? ? mychar.style.backgroundColor="blue";
}
//定義"改變寬高"的函數
function cgwh(){
? ? mychar.style.width="300px";
? ? mychar.style.height="500px";
//定義"隱藏內容"的函數
function hidetext(){
? ? mychar.style.display="none";
//定義"顯示內容"的函數
function showtext(){
? ? mychar.style.display="block";
//定義"取消設置"的函數
function rst(){
? ? tag = confirm("是否恢復默認?");
? ? if(tag)
? ? {
? ? mychar.removeAttribute("style");
? ? }
? ??
? </script>
愛媛兒 提問者
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
4 回答編程練習求大神修改
1 回答編程練習求教
5 回答敢問 編程在哪里練習?怎么練習? ?
7 回答求2-7編程練習答案
2 回答求教, 第二章的編程練習
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-05-26
個人代碼,可以互相切磋交流?
<input type="button" onclick="cgColor()" value="改變顏色" > ?
? ? <input type="button" onclick="cgwh()" value="改變寬高" >
? ? <input type="button" onclick="hidetext()" value="隱藏內容" >
? ? <input type="button" onclick="showtext()" value="顯示內容" >
? ? <input type="button" onclick="rst()" value="取消設置" >
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數
function cgColor(){
? ? mychar = document.getElementById("txt");
? ? mychar.style.color="red";
? ? mychar.style.backgroundColor="blue";
}
//定義"改變寬高"的函數
function cgwh(){
? ? mychar = document.getElementById("txt");
? ? mychar.style.width="300px";
? ? mychar.style.height="500px";
}
//定義"隱藏內容"的函數
function hidetext(){
? ? mychar = document.getElementById("txt");
? ? mychar.style.display="none";
}
//定義"顯示內容"的函數
function showtext(){
? ? mychar = document.getElementById("txt");
? ? mychar.style.display="block";
}
//定義"取消設置"的函數
function rst(){
? ? mychar = document.getElementById("txt");
? ? tag = confirm("是否恢復默認?");
? ? if(tag)
? ? {
? ? mychar.removeAttribute("style");
? ? }
? ??
}
? </script>