国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS實現(xiàn)改變HTML上文字顏色和內(nèi)容的方法

2019-11-19 18:11:10
字體:
供稿:網(wǎng)友

本文實例講述了JS實現(xiàn)改變HTML上文字顏色和內(nèi)容的方法。分享給大家供大家參考,具體如下:

1. JavaScript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> Day 1 </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script>  // to change the color of an object.  function changeColor(){  x=document.getElementById("Id1");  x.style.color="Red";  }  // to change the content of an object.  function changeContent(){  y=document.getElementById("Id2");  y.innerHTML="Hi, you have changed the contents using Java Script successfully!";  }  </script> </HEAD><BODY bgcolor="AntiqueWhite">  <h1 ><center>Welcome Page</center></h1>  <p id="Id1">It is test 1.</p>  <p id="Id2">It is test 2.</p>  <button type="button" onclick ="changeColor()">    Change color of test 1  </button><br/><br/>  <button type="button" onclick ="changeContent()">    Change content of test 2  </button> </BODY></HTML>

2. Day 1.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> Day 1 </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> <script>  // to change the color of an object.  function changeColor(){  x=document.getElementById("Id1");  x.style.color="Red";  }  // to change the content of an object.  function changeContent(){  y=document.getElementById("Id2");  y.innerHTML="Hi, you have changed the contents using Java Script successfully!";  }  </script> </HEAD><BODY bgcolor="AntiqueWhite">  <h1 ><center>Welcome Page</center></h1>  <p id="Id1">It is test 1.</p>  <p id="Id2">It is test 2.</p>  <button type="button" onclick ="changeColor()">    Change color of test 1  </button><br/><br/>  <button type="button" onclick ="changeContent()">    Change content of test 2  </button> </BODY></HTML>

3. 運行效果截圖:

PS:這里再提供幾款文字特效工具供大家參考:

在線特效文字/彩色文字生成工具:
http://tools.VeVB.COm/aideddesign/colortext

在線生成字體CSS樣式工具:
http://tools.VeVB.COm/code/csscreate

仿古書排版文字豎排轉(zhuǎn)換工具:
http://tools.VeVB.COm/transcoding/shupai

線條字生成工具:
http://tools.VeVB.COm/transcoding/xiantiaozi

在線鋼筆手寫體/手寫字生成工具:
http://tools.VeVB.COm/aideddesign/shouxiezi

更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript切換特效與技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript動畫特效與技巧匯總》、《JavaScript錯誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》及《JavaScript數(shù)學(xué)運算用法總結(jié)

希望本文所述對大家JavaScript程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 太仓市| 拜泉县| 铁力市| 成安县| 临城县| 贵德县| 故城县| 尉犁县| 分宜县| 灌云县| 凤山市| 台东县| 平顺县| 琼海市| 峡江县| 黄龙县| 双流县| 昆山市| 湖南省| 论坛| 龙门县| 海安县| 磴口县| 丰顺县| 惠来县| 隆子县| 科技| 阜平县| 枣强县| 定日县| 彭泽县| 嘉义市| 类乌齐县| 海伦市| 台北市| 都昌县| 常州市| 周口市| 阳信县| 潮州市| 调兵山市|