<a title="qwe">标签里 加onclick ,点击则在一个input里显示出qwe来,怎么搞?   有好多<a> 点那个显示那个的title值。

解决方案 »

  1.   

    给input加个id
    <a title="qwe" onclick="document.getElementById('ipt').value=this.title" />
      

  2.   

    如果你有很多这种a标签的话,那么将onclick的代码封装一下
    <script>
      function ck(obj){
        document.getElementById('ipt').value=obj.title;
      }
    </script>
    <a title="qwe" onclick="ck(this)" />
      

  3.   


    <body>
    <a title="asdf" href="#">asdf</a><a title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" />
    </body>
    <script>
        $('a').click(function() {
            $("#txtValue").val($(this).attr("title"));
        })
    </script>
      

  4.   

    <!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=utf-8" />
    <title>无标题文档</title>
    </head><body>
    <a href="#" title="11">11</a><input type="text" /><br />
    <a href="#" title="22">22</a><input type="text" /><br />
    <a href="#" title="33">33</a><input type="text" /><br />
    <script>
    var as = document.getElementsByTagName('a');

    for(var i = 0,a; a = as[i++];){
    if(a.title){
    a.onclick = function(){
    this.nextSibling.value = this.title;
    return false;
    };
    }
    }
    </script>
    </body>
    </html>
    给你写了个例子~·如果要用的话,看好我的结构~·要不你还得改JS代码~`
      

  5.   

    我现在只需要一个input就行了,  然后点那个<a>,这个input就显示谁的,你的代码太高级了。
      

  6.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>    <script src="../js/jquery-vsdoc.js" type="text/javascript"></script>    <script src="../js/jquery.js" type="text/javascript"></script></head>
    <body>
    <a title="asdf" href="#">asdf</a><a title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" />
    </body>
    <script>
        $('a').click(function() {
            $("#txtValue").val($(this).attr("title"));
        })
    </script>
    </html>
    之前要引用jquery
      

  7.   

    ok了,结贴前想问一句
        <script src="../js/jquery-vsdoc.js" type="text/javascript"></script>    <script src="../js/jquery.js" type="text/javascript"></script>   /jquery-vsdoc.js 这个是干什么的?   我只引用了jquery.js 就成功了。   他俩一样吗
      

  8.   


     <script src="../js/jquery-vsdoc.js" type="text/javascript"></script>  <script src="../js/jquery.js" type="text/javascript"></script>   
    上面那个是我vs2008  jquery提示的  你引用下面那个就OK了...