I have custom element which has an input element that is not a first grade child. I want to get the parent custom element from the input and I tried using input.closest()
but it does not work with custom elements tag names
const card = input.closest("game-card");
I need to get the first parent that is a game card so is there a way to do this with custom elements?
2
Answers
the closest method parameter would be :
use ‘#game-card’, if custom parent element have id=’game-card’
or
use ‘.game-card’, if custom parent element have class=’game-card’.
your problem will be resolved.