<script type="text/javascript">
  function otherls(){
  
 var th= document.getElementsByName("names");
 for(var i=0; i<th.length;i++){
 var one=th[i];
//怎么写了????????????
 one.style.textDecoration="underline"; }
  }
<a href="" name="names" onmouseover="otherls()">
<a href="2." name="names">当我鼠标浮到上时..对应的a  下划线显示  其余的不显示

解决方案 »

  1.   

    css 简单解决,a:hover{text-decoration:underline;}
      

  2.   

    <a href="" name="names">111</a>
    <a href="2." name="names">222</a>
    <a href="" name="names">333</a>
    <script type = "text/javascript" >
    var th = document.getElementsByName('names');
    for(var i = 0; i < th.length; i ++) {
    th[i].onmouseover = function() {
    for(var j = 0; j < th.length; j ++) th[j].style.textDecoration = 'none';
    this.style.textDecoration = 'underline';
    }
    }
    </script>
      

  3.   

    恩 是的 这个问题不需要使用js 楼主使用js反而变麻烦了 
    把楼上的样式加到你的html代码的style标签里就行了