开发者

How do I add an object/this to a string in $$ selector in prototype?

$element = $(element);
console.log($$("#" + element + " > p")[0]); // works
console.log($$($element + $$(" > 开发者_运维知识库p"))[0]); // something like this


I think you want "#" + element.id — though it seems a lot more sensible to write $(element).select('p').


Use the select method of the element itself:

$element.select('p')[0]


I'm rusty at Prototype but I think that if you want to find all the <p> elements that are direct children of some element you've already got, you'd do this:

var firstPara = $(element).find(function(e) { return e.tagName.toUpperCase() === 'P'; });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜