From 5b6d8c83dbd523eaf8dc14cd2b92a4832fd1263c Mon Sep 17 00:00:00 2001 From: 39zde Date: Thu, 10 Oct 2024 14:17:38 +0200 Subject: [PATCH] fix selection method --- index.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index a92f133..39c9f6b 100644 --- a/index.js +++ b/index.js @@ -18,10 +18,13 @@ function checkBrowserCompatibility() { function keyDownClicker(event) { event.preventDefault(); if (event.key === "Enter") { - let labelElement = event.target; - let inputElement = labelElement.queySelector("input"); - console.log(labelElement); - console.log(inputElement); + let inputElement; + for (const elem of event.target.children) { + if (elem.tagName === "INPUT") { + inputElement = elem; + break; + } + } if (inputElement) { inputElement.click(); } else { @@ -69,7 +72,13 @@ function cycler(selectElement) { function keyDownCycler(event) { event.preventDefault(); if (event.key === "Enter") { - let selectElement = event.target.queySelector("select"); + let selectElement; + for (const elem of event.target.children) { + if (elem.tagName === "SELECT") { + selectElement = elem; + break; + } + } if (selectElement) { cycler(selectElement); } else {