$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'; });
精彩评论