http://topic.csdn.net/u/20090812/09/a563f26d-c85f-40fa-870c-1115ae13e6b3.html 
和以上的这个链接里边相似的效果,不过要使用jQuery完成效果。请大家帮帮忙~~感恩~~~

解决方案 »

  1.   


    <input id = "test" type="text" />
    <div id = "testlink">
      <a href="javascript:;">link1</a>
      <a href="javascript:;">link2</a>
      <a href="javascript:;">link3</a>
    </div>function addstr(){
      var $text = $("#test").val() + " " + $(this).text()
      $("#test").val($.trim($text));
    }
    function removestr(){
      var $text = $(this).text();
      var retext = new RegExp($text+" ?" , "g");
      $text = $("#test").val().replace(retext,"");
      $text = $.trim($text);
      $("#test").val($text);
    }
    $(function (){
      $("#testlink a").click(toggle(addstr,removestr));
    });
      

  2.   

    小失误- -$(function (){
      $("#testlink a").click(toggle(addstr,removestr));
    });错了,改成$(function (){
      $("#testlink a").toggle(addstr,removestr);
    });
      

  3.   

    加上链接的显示效果,最后的代码:<html>
     <head>
      <title>test</title>
      <script type="text/javascript" src="jquery.js"></script>
      <script type="text/javascript">
      <!--
      function addstr(){
        var $text = $("#test").val() + " " + $(this).text()
        $("#test").val($.trim($text));
        $(this).attr("style","background-color:#ccc;");
      }
      function removestr(){
        var $text = $(this).text();
        var retext = new RegExp($text+" ?" , "g");
        $text = $("#test").val().replace(retext,"");
        $text = $.trim($text);
        $("#test").val($text);
        $(this).attr("style","");
      }
      $(function (){
        $("#testlink a").toggle(addstr,removestr);
      });
      //-->
      </script>
     </head>
     <body>
      <input id = "test" type="text" />
      <div id = "testlink">
       <a href="javascript:;">link1</a>
       <a href="javascript:;">link2</a>
       <a href="javascript:;">link3</a>
      </div>
     </body>
    </html>