jquery 怎么获取所有页面上所以的 <a href>之类的标签,
  
 如:  <a href="a.html">点击一</a>
      <a href="b.html">点击一</a>然后将所有获得的这样的超链接的disabled设为true,即灰掉,不能点???

解决方案 »

  1.   

    <script language="javascript">
    $("a").each(function(){$(this).attr("href","javascript:void(0)").css("color","#ccc")})
    </script>
      

  2.   


    var aElements = document.getElementsByTagName("a")
    for(var i=0;i<aElemenets.length;i++){
        aElements[i].disabled = true;
    }
      

  3.   

    按楼主的要求是这样的,但是没有效果$("a").each(function(){
        $(this).attr("disabled",true);
    })//获得所有的a标签
      

  4.   

    楼主    A 标签没有  disabled属性,只有 input 标签才设置这个属性!!
      

  5.   


    $("a").each(function(){
    $(this).attr("href","javascript:void(0)").css("color","#ccc").attr("text-decoration","none");
    })//这样应该符合你的要求了
      

  6.   


    $("a").each(function(){
    $(this).attr("href","javascript:void(0)").css("color","#ccc").css("text-decoration","none");
    })//获得所有的a标签这样,刚才的不算好
      

  7.   

    $("a").attr("disabled","disabled").click(function(){return false;});
      

  8.   

    http://blog.csdn.net/bennman/archive/2010/04/16/5492804.aspx
      

  9.   

    直接所有的  href 设置为  javascript:void(0);
    var a = document.getElementsByTagName('a');
    var len=a.length;
    for(var i=0;i<len;i++){
        a.href = javascript:void(0);
    }
      

  10.   

    不用each的吧,自己会循环的。$("a").removeAttr("href").css({"color":"#ccc","text-decoration":"none"});
      

  11.   

    要不能点,必须去掉href  
      

  12.   


    这个就行了  href没有disable这个属性   用void(0) 也行   虽然能点 但点了没起作用 也能实现你的效果啊
      

  13.   

    如果变灰之后不用再变回可以点的状态就这样function ff()
    {
    $("a").each(function(){
    $(this).removeAttr("href");
    $(this).attr("style","color:#CCC;");
    })}
    //调用ff()如果变灰之后还要变回来就这样function ff(type)
    {
    $("a").each(function(){
    if(type==1)
    {
    $(this).attr("onclick","return false");
    $(this).attr("style","color:#CCC;");
    }
    else
    {
    $(this).removeAttr("onclick","return false");
    $(this).attr("style","color:#00f;");
    }
    })}
    //调用ff(1)变灰不能点 调用ff(0)恢复能点状态
      

  14.   

    呃 错了 倒数第五行应该是
    $(this).removeAttr("onclick");
    多了个参数
      

  15.   

    楼上的,你自己试过没有?据我所知,remove onclick 这个属性会有问题,某些浏览器会认不出来,如果要以上效果可以使用die live 来实现。