开发者

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

开发者 https://www.devze.com 2023-02-01 11:37 出处:网络
$element = $(element); console.log($$(\"#\" + element + \" > p\")[0]); // works console.log($$($element + $$(\" > 开发者_运维知识库p\"))[0]); // something like this
$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

精彩评论

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