<SPAN>张三,李四</SPAN>如何实现当鼠标滑过 [李四] 时 [李四]二字变色 而[张三]不变色
同理 [张三] 时 [张三]二字变色 而[李四]不变色

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    </head>
    <style type="text/css">#a , #a:visited{ color:#000; text-decoration:none}
    #a:hover,#a:active{ color:Red; text-decoration:none}
    </style>
    <body>
    <SPAN>
    <a href="#" id="a">张三</a>

    <a href="#" id="a">李四</a></SPAN>
    </body>
    </html>
      

  2.   

    HTML代码已经确认为
    <SPAN>张三,李四</SPAN>
    如何在不修改此段HTML代码的基础上实现
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    </head>
    <style type="text/css">#a , #a:visited{ color:#000; text-decoration:none}
    #a:hover,#a:active{ color:Red; text-decoration:none}
    </style>
    <body>
    <SPAN id="s">
    张三,李四
    </SPAN>
    <script type="text/javascript">
    var span = document.getElementById("s");
    var str = span.innerHTML;
    var arr = str.split(",");
    str ="";
    str += "<a href='#' id='a'>"+arr[0]+"</a>";
    str += ",";
    str += "<a href='#' id='a'>"+arr[1]+"</a>";
    span.innerHTML = str;
    </script></body>
    </html>
    不修改不能变色的
      

  4.   


    用Js捕捉事件,插入span环绕李四,为新span注入class换颜色
      

  5.   


    想法是对的,但span嵌套后会碰到事件冒泡的问题,这个问题处理起来比较困难。