ortunado β 17-21 Nov 8
Could anyone have idea, how to manage querySelectorAll to select all input elements, but not the ones inside another form? For example,
29 Replies
The easiest would be to use
element.closest()
but could there be any other way?Which inputs do you want here?
Can you annotate them please
Edited the original message.
This is the current version with JS, would like to not use
element.closest
Query selector CSS power πͺ that's really nice π digging around doing a React 18 upgrade but I probably would've come up with something a bit worse anyway
And we need remove last small thing.
Right now any depth.
π
Beautiful bit of DOM work there
Also we can merge rules:
And form cannot be in form.
Can you merge query selector selectors like that in the same way you can merge CSS ruleset selectors?
I never knew that
Right.
Damn, TIL
<a:7119_Jotaro_Dancing:608310437955502146>
Haven't had to work with the DOM at a low level for a few years now but that's wicked!
Although as an aside, I don't think it's semantically correct to nest forms anyway so π€·ββοΈ
Same, now lying in bed a little sick recovered it from memory and docs.
The days before querySelector were doom and gloom
The DOM methods are so powerful but god forbid I have to work with them at that low a level again
Edit fiddle - JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
This seems to get all the inputs expect the one after, may I be doing something wrong?
Thanks for great help π
Yes, I do agree nesting forms are kinda lame, and you need to do some kind of magic, to match each submit, not really sure why the colleagues have done that.
If that's internal code that you own then you should just fix it IMO. Nesting forms isn't okay
Has someone been documenting their solutions? a nice idea if so
Yep, yep! π Inside vite a couple of nice libs like:
generouted
U can take a look folder: tech
is about different things! π And issues - it's about solutions.Very nice!
That's a really cool idea
May I ask, how would I edit it, if the 2nd form is, for example, nested deeper in divs?
Don't know about any depth, maybe need to go to xpath.
ok thanks
Solved.
Example in repo updated @ortunado
@EvokeMe Thanks for your persistence, what a interesting way to solve it. β€οΈ
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
This thread hasnβt had any activity in 12 hours, so itβs now locked.
Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1039590471149813850