JS: Check whether one element is a child of another