Alice Wonder
Alice Wonder

Reputation: 916

JavaScript getElementsByTagName within specific container

In php, I can use getElementsByTagName on any DOM object but it seems JavaScript does not have that concept.

IE if the var detailsNode is a specific node, detailsNode.getElementsByTagName('summary') does not seem to work, firebug error says detailsNode.getElementsByTagName is not a function.

So, how do I target getElementsByTagName() to only look within a specified DOM element in JavaScript?

Thank you for suggestions.

Oh, and the answer needs to be straight up DOM2 method, no jQuery for this (where it would be easy).

Upvotes: 1

Views: 612

Answers (1)

khael
khael

Reputation: 2610

Element and Node objects do have getElementsByTagName which returns an array of the found elements in the given Element/Node.

Upvotes: 2

Related Questions