今天上午问了问题,下午解决了,现在发现出了一点小问题。<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>就这个,  这个好象是整个页面的所有<a>都受到了控制,我只想让指定的某几个<a>链接产生这种效果,其他<a>不受这个js影响。  怎么弄啊。   怪我问问题时候没考虑清楚。  

解决方案 »

  1.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js"></script></head>
    <body>
    <a class="ab" title="asdf" href="#">asdf</a><a class="ab" title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" />
    </body>
    <script>
        $('a.ab').click(function() {
            $("#txtValue").val($(this).attr("title"));
        })
    </script>
    </html>
      

  2.   

    class或者name都可以
    $(a[name='name1']).click(function(){});
      

  3.   

    <a class="test" title="asdf" href="#">asdf</a><a class="test" title="qwer" href="#">qwer</a><a title="test" href="#">zxcv</a><script>
        $('.test').click(function() {
            $("#txtValue").val($(this).attr("title"));
        })
    </script>
      

  4.   

    可以给需要效果的a自定义一个属性,比如rel,然后在事件处理函数里判断getAttribute(rel)是否存在。
      

  5.   

    对你相应操作的A标签加个ID或者Name或者Class  
      

  6.   

    正如一楼所写,用css选择器就行了ID、class、name