东湖
这个词是有链接的,
我单击 东湖时,希望  东湖 二字能 变红色和变粗,怎么实现呀,谢谢

解决方案 »

  1.   


    <script>
        function change(obj){
            obj.style.color="red";
            obj.style.fontWeight=800;
        }
    </script>
    <div onclick="change(this)">东湖</div>
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script type="text/javascript">
    window.onload = function(){
    document.getElementById('a').onclick = function(){
    this.style.color = 'red';
    this.style.fontWeight = 'bold';
    };
    }
    </script>
    </head><body>
    <a href="#" id="a">东湖</a>
    </body>
    </html>
      

  3.   


    <script>
        var lastobj;
        function change(obj){
            if(lastobj) {
                lastobj.style.color="black";
                lastobj.style.fontWeight=200
            }
            obj.style.color="red";
            obj.style.fontWeight=800;
            lastobj=obj
        }
    </script>
    <div onclick="change(this)">东湖</div><div onclick="change(this)">西湖</div>
      

  4.   

    L@_@K
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
      <style type="text/css">
    a
    {
    color: blue;
    }  </style>
     </head> <body>
      我单击 <a href="#">东湖</a>时,希望  <a href="#">东湖</a> 二字能 变红色和变粗,怎么实现呀,谢谢<br />
      <a href="#">东湖</a>、<a href="#">东湖</a>、<a href="#">东湖</a>
     </body>
     <script type="text/javascript">
     <!--
    var cA = document.getElementsByTagName("a");
    for (var i=0; i<cA.length; i++)
    {
    cA[i].onclick = function(){
    if (this != document.body.currentLink)
    {
    if(document.body.currentLink)
    {
    document.body.currentLink.style.color = "";
    document.body.currentLink.style.fontWeight = 'normal';
    } this.style.color = 'red';
    this.style.fontWeight = 'bold'; document.body.currentLink = this;
    }
    };
    }
     //-->
     </script>
    </html>
      

  5.   

    简单一点,用CSS就可以实现<html>
    <head>
    <style>
    a:link{
     font-family:"宋体";
     font-size:24px;
     color:#666666;
    }
    a:hover{
     font-family:"宋体";
     font-size:24px;
     color:blue;
    }
    a:visited{
     font-family:"宋体";
     font-size:24px;
     color:red;
     font-weight:bold;
    }
    </style>
    </head>
    <body>
    <a href="#">东湖</a>
    </body>
    </html>  a:link{}这里面的属性定义的是链接最开始的状态,鼠标还没有点击过
       a:hover{}这里面的属性定义的是当鼠标放在这个连接上但是还没有点击的状态
        a:visited{}这里面的属性定义的是鼠标点击过后的状态。鼠标点击过后会一直保持这个状态,除非刷新,或者删除浏览过的历史记录以后再刷新。如果你不需要那种状态可以删掉,每种状态可以根据自己的需求来设置css样式
      

  6.   

    我这里定义的是:鼠标还未点击时,链接文字是灰色,宋体,24px;鼠标经过时,链接文字是蓝色,宋体24px;鼠标点击过后,链接文字是红色,宋体,24px,加粗。楼主可以拿这段代码去试一试效果。
      

  7.   

    a:visited
    {
    font-weight:bold;
    }
    <a href="#" onclcik="this.style.fontWeigh=400"
      

  8.   

    一看楼主的需求,就知道要用css做,这是最好的做法。顶9楼
      

  9.   

    像这类操作最好就是用CSS CSS能解决的问题就不要用js
      

  10.   

    js和css都可以解决,就看楼主需要怎样了