你那个如何来换呀,上面地通过HTC不可能地
就象你坐在凳子上力气再大也不可能把凳子搬起来地呀
下面你参考<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<style type="text/css">
.nolink{
color:blue;
}
.link{
color:green;
}
</style>
</head>
<body>
<SPAN ID="first" CLASS="nolink">First</SPAN>
<SPAN ID="last" CLASS="link">LAST</SPAN>
<script>
document.body.attachEvent("onclick",bbb);
var flag=0;
function bbb()
{
if(event.srcElement.tagName == "SPAN"&&flag==0)
{
document.all.first.className='link';document.all.last.className='nolink';
flag=1;
}
else
{
document.all.first.className='nolink';document.all.last.className='link';
flag=0;
}
}
</script>
</body>
</html>

解决方案 »

  1.   

    flyskytoday(路要靠自己走.光风) 
    你好:
       你的方案和建议都很好。现在样式效果也实现了,但我还想在单击First后,只能单击LAST;单击LAST后,只能单击FIRST。即他们两个同时只能有一个能有单击事件。两者是排他性的。
      

  2.   

    再加一个判断啊...<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    <style type="text/css">
    .nolink{
    color:blue;
    }
    .link{
    color:green;
    }
    </style>
    </head>
    <body>
    <SPAN ID="first" CLASS="nolink">First</SPAN>
    <SPAN ID="last" CLASS="link">LAST</SPAN>
    <script>
    document.body.attachEvent("onclick",bbb);
    var flag=0;
    function bbb()
    {
    if(event.srcElement.tagName == "SPAN"&&flag==0&&window.event.srcElement.className=='link')
    {
    document.all.first.className='link';document.all.last.className='nolink';
    flag=1;
    }
    else if(event.srcElement.tagName == "SPAN"&&flag==1&&window.event.srcElement.className=='link')
    {
    document.all.first.className='nolink';document.all.last.className='link';
    flag=0;
    }
    }
    </script>
    </body>
    </html>
      

  3.   

    只是互换样式的话
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    <style type="text/css">
    .nolink{
    color:blue;
    cursor:hand;
    }
    .link{
    color:green;
    cursor:hand;
    }
    </style>
    </head>
    <body>
    <SPAN ID="first" CLASS="nolink">First</SPAN>
    <SPAN ID="last" CLASS="link">LAST</SPAN>
    <script>
    document.body.attachEvent("onclick",aaa);
    var flag=0;
    function aaa() {
     var t=document.all.first.className;
     document.all.first.className=document.all.last.className;
     document.all.last.className=t;
    }</script>
    </body>
    </html>