<a show="rp1">aaaaaaaa</a><div id="rp1" style="display:none;position:absolute;z-index:99;background-color:Red;">测试Attribute控制属性</div><br />
<a show="rp2">bbbbbbbb</a><div id="rp2" style="display:none;position:absolute;z-index:99;background-color:Red;">哇哇哇啊哇哇哇网哇哇</div>
<br />
<input type="text" info="天河区" id="txt1" />
<input type="text" info="中山大道" id="txt2" />
<script type="text/javascript">
(function(){
elist = document.getElementsByTagName("*");
for(var e=0;e<elist.length;e++){
var t=elist[e],a=t.getAttribute("show"),b=t.getAttribute("info");
if(a!=null){ /// 鼠标显示与隐藏
t.setAttribute("onmouseover","showtooltip('"+a+"')");
t.setAttribute("onmouseout","hidetooltip('"+a+"')");
}
if(b!=null){ /// 显示文本例文
showinfo(t.id);
t.setAttribute("onfocus","clearinfo(this.id)");
t.setAttribute("onblur","showinfo(this.id)");
}
}
})();
function $g(o){return document.getElementById(o);};
function showtooltip(o){$g(o).style.display="block";};
function hidetooltip(o){$g(o).style.display="none";};
function clearinfo(o){g=$g(o);if(g.value==g.getAttribute("info")){g.value="";g.style.color="Black";}};
function showinfo(o){g=$g(o);if(g.value.replace(//s/g,"")==""){g.value=g.getAttribute("info");g.style.color="Red";}};
</script>