Frage im Vorstellungsgespräch bei X

Implement the getElementsByClassName(element, className) function in Javascript.

Antwort im Vorstellungsgespräch

Anonym

23. Jan. 2012

Walk the DOM from the given parent node, looping along the element.nextSibling pointer. If the current node in the loop has children, you can call the getElementsByClassName function recursively. Keep in mind that it's not a straight string comparison, because elements can have multiple classes.

2