<label for="lbl1">1</label>
<label for="">2</label>
<label>3</label>
----------------------------
用Jquery找出第三个要怎么找,
要一次定位到谢谢

解决方案 »

  1.   

    <label>3 </label> 
    -----------
    这个,
    也就是没有注意for属性的label
    谢谢
      

  2.   

    var res=$("label").filter(function(){
        if(this.getAttribute("for")===null)//If the attribute is not present, this method returns null. 
            return true;
    }).html();
    alert(res)
      

  3.   

    ===
    ---------
    javascript === 是什么意思?
      

  4.   

    var res=$("label").filter(function(){
        if(this.hasAttribute && !this.hasAttribute("for") || this.getAttribute("for")===null)
        //MSDN:If the attribute is not present, this method returns null. 
        //MDC:If the named attribute does not exist, the value returned will either be null or "" (the empty string); 
        //如果不考虑IE6可以直接使用hasAttribute判断
            return true;
    }).html();
    alert(res)
      

  5.   

    alert(undefined==null)//判断值
    alert(undefined===null)//===判断引用
      

  6.   

    那样麻烦了. $(function() {
    alert($('label').not($('label[for]')).html())
    });
      

  7.   

    上面写的ie6跟7应该有问题,修改下:var res=$("label").filter(function(){    
        if((this.hasAttribute && !this.hasAttribute("for")) || (!this.getAttributeNode("for").specified))
            return true;
    }).html();
    alert(res)