Pregunta de entrevista de X

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

Respuesta de la entrevista

Anónimo

23 ene 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