Javascript Function Find Element by Traversing Parent Elements

Javascript Function Code that Allows you to Find a Parent Element, Relative to the Current Element the Mouse has Passed over or Clicked. The Return of this JS Function is the Element Object, if Found, and an Array of the Parent Elements

Home Short:

The simple Javascript function code below allows you to start with an element and traverse up the parent nodes until you hit the first element with a tagname that matches the parent element you are looking for.

Example #1:

Example #2:

S
H
A
R
E