[英]YUI nested selectors
I am a YUI(AUI) beginner. 我是YUI(AUI)初学者。 In jQuery I would do
在jQuery中,我会做
$(image).find(selector).text();
How can this be achieved in YUI? 如何在YUI中实现?
AUI().use('event', 'node', function(A) {
var subImages = A.all('.sub_image_conatiner');
for (var i = 0; i < subImages.size(); i++){
var image = subImages.get(i);
//get child elements of image here
}
});
I thought Y.all(foo).all(selector).get('text')
would just work but it unfortunately doesn't. 我以为
Y.all(foo).all(selector).get('text')
可以工作,但不幸的是,它没有工作。
I'd recommend that you use only one selector to match the sub elements: 我建议您仅使用一个选择器来匹配子元素:
Y.all('.parent-class .child-class').get('text');
If you can't, then you don't have to iterate through the nodes like a normal JS array. 如果不能,则不必像普通的JS数组那样遍历节点。 You can use
.each()
. 您可以使用
.each()
。
var texts = [];
Y.all(foo).each(function (node, i) {
texts = texts.concat(node.all(bar).get('text'));
});
console.log(texts);
I'll file a bug with YUI to see if it makes sense to add Y.NodeList.prototype.all
我将向YUI提交一个错误,以查看添加
Y.NodeList.prototype.all
是否有意义
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.