<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>index</title> <style> *{ font-family: 微软雅黑; } </style> </head> <body> <h1 info='linux is very much!' id='hid' class='hcls'>linux is very much!</h1> </body> <script> hidobj=document.getElementById('hid'); function getA(obj,attr){ //传值 对象 属性 return obj.getAttribute(attr); } alert(getA(hidobj,'class')); function setA(obj,attr,value){ obj.setAttribute(attr,value); } setA(hidobj,'info','php is very much!'); //改变info属性得值为 php is very much 浏览器中看不到,在代码中看得到 </script> </html>