all

Module

Methods

NodeList.prototype.all()
NodeList all ( selector )
得到当前节点列表内符合选择器字符串的子孙节点列表
Parameters:selector (string) – 选择器字符串
Return type:NodeList

实际上是

NodeList.prototype.all=function(selector) {
    if (this.length > 0) {
        return NodeList.all(selector, this);
    }
    // 否则空节点列表
    return new NodeList();
};

举例

<!DOCTYPE html>
<html>
<head>
    <style>
        button { margin:10px; }
    </style>
    <script src="//g.alicdn.com/kissy/k/1.4.7/seed.js" data-config="{combine:true}"></script>
</head>
<body>
    
    <div class='outer' id='s'>
        <div class='item'>
            item1
        </div>
    </div>
    
    <div class='outer'>
        <div class='item'>
            item2
        </div>
    </div>
    
    <div class='item'>
        item3
    </div>
    
    <button>$(".item")</button>
    <button>$(".outer").all(".item")</button>
    <button>$("#s").all(".item")</button>
    
<script>
    KISSY.use('core',function (S) {
        var $=S.all;
        $("button").on("click",function(){
            $("div").css("color","");
            var el=$(this);
            var content=el.html();
            eval(content).css("color","red");
        });
        
    });
</script>
</body>
</html>