是不是你的脚本在 <a id="antares" href="antares.html" title="A far away place">Antares </a> 出现之前就运行了....下面这个没问题<a id="antares" href="antares.html" title="A far away place">Antares </a> <script type="text/javascript">
var anchor = document.getElementById("antares"); 
anchor.setAttribute("title", "Not that far away"); 
</script>

解决方案 »

  1.   

    你确认anchor已经取道了吗?在设置属性前你alert(anchor.innerHTML)看一下。很有可能是你的语句是没有问题的但你执行的时候anchor对象还没有生成。
      

  2.   

    1.注意一下函数执行的位置;
    2.清除一下缓存试试。
    3.good luck !!
      

  3.   

    <a id="antares" href="antares.html" title="A far away place">Antares </a> <script type="text/javascript">var anchor = document.getElementById("antares");
    anchor.setAttribute("title", "Not that far away");</script>这是OK的