<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Day 1 </TITLE> <META CONTENT="EditPlus"> <META CONTENT=""> <META CONTENT=""> <META 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>It is test 1.</p> <p>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 CONTENT="EditPlus"> <META CONTENT=""> <META CONTENT=""> <META 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>It is test 1.</p> <p>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:这里再提供几款文字特效工具供大家参考:
在线特效文字/彩色文字生成工具:
更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript切换特效与技巧总结》、《JavaScript遍历算法与技巧总结》、《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》及《JavaScript数学运算用法总结》