<textarea id="runcode14159"><! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title>javascript getelementbytagname use </title> <style type=" Text/css ">. dd1{color: #FF0000; }. dd2{Color:blue; } </style> <script type= "Text/javascript" > Function ChangeColor () {//document.getelementbyid ("S1"). Getel Ementsbytagname ("a"). Classname= "DD2"; var obj1,num,i; Obj1=document.getelementbyid ("S1"). getElementsByTagName ("a"); Num=document.getelementbyid ("S1"). getElementsByTagName ("a"). Length; for (i=0;i<num;i++) {obj1[i].classname= "DD2"; } </script> </pead> <body> <div id= "S1" onmouseover= "ChangeColor ()" > DFDFD dfdfd DFDFD </div> </body> </ptml></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]