读写属性1:
<p>
<a id="antares" href="test1.htm" title="Marssion">Antares</a>
</p>
var anchor=document.getElementById("antares");
var anchorId=anchor.getAttribute("id");
var anchorTitle=anchor.getAttribute("title");
alert("The anchor ID is:"+anchorId+"\nThe anchor title is:"+anchorTitle);
读写属性2:
<p>
<a id="antares" href="test2.htm" title="Marssion">Antares</a>
</p>
var anchor=document.getElementById("antares");
anchor.setAttribute("title","Marssion.lee");
var newTitle=anchor.getAttribute("title");
alert("The anchor title is:"+newTitle);