标签:blog dem window for doc html 颜色 utf-8 程序
<html> <head> <title>demo</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> /* 示例操作DOM元素 */ window.onload = function(){ //给Dom元素添加颜色 var li = document.getElementsByTagName("li"); for(var i=0;i<li.length;i++){ li[i].style.color = "red"; li[i].onmouseover = function(){ this.style.color = "blue"; } li[i].onmouseout = function(){ this.style.color = "red"; } } } </script> </head> <body> <ul> <li>李老师-英语</li> <li>张老师-数学</li> <li>刘老师-物理</li> </ul> </body> </html>
触发时,文本出现颜色。事件是黏合应用程序中所有用户交互的胶水。DOM和事件的是JavaScript中的黄金搭档
标签:blog dem window for doc html 颜色 utf-8 程序
原文地址:http://www.cnblogs.com/dexin/p/6308697.html