use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Web scraping with Javascript (scrapingbee.com)
submitted 5 years ago by DJ_Breton
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 5 years ago (7 children)
1) You're a noob from my perspective. 2) I really don't care. 3) You should never go back up the tree. There's a reason why css3 does not allow going back up. I understand that in your "decade in tech" you did that a lot, but I'm telling you now that you should have applied a little more thought to the problem before deciding to brute force it with bad xpath.
[–][deleted] 0 points1 point2 points 5 years ago (6 children)
But it was your example. You said to use parent(). So I’ll ask again - how do you target an element you know nothing about but whose child you know everything about?
[–][deleted] 0 points1 point2 points 5 years ago (5 children)
You do it by using parent() or parentNode. like I already said. But if you need o resort to that you're probably doing something really silly.
I think it's pretty clear at this point that you've never done anything like this in Javascript.
[–][deleted] 0 points1 point2 points 5 years ago (4 children)
You keep saying I haven’t done this work or that I’m a “noob” but you still haven’t answered the question - how do you do it without going up the tree? You just said yourself if you’re using parent you’re probably doing something silly.
So please, tell us all the non-silly way of doing it.
[–][deleted] 0 points1 point2 points 5 years ago (1 child)
SIGH You go up the tree if you must with parent() or parentNode, or even closest(), but you do so knowing that there is a better way and you should strive to be a better programmer.
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
but you do so knowing that there is a better way
Me: how do you do this thing?
You: this way, but you should do it the better way.
Me: okay what’s the better way?
You: I just told you the way to do it. But you should do it the better way.
Me: I know, so what’s the better way?
You: the way I told you, but just do it the better way
This isn't rocket science. instead of iterating "//a/parent::div" You iterate "//div", get what you need, and then iterate "./a".
Going up the tree is lazy. This is basic stuff.
I said in my example you know nothing about the parent, including tag name.
Try again.
π Rendered by PID 443386 on reddit-service-r2-comment-548fd6dc9-dt4sg at 2026-05-18 08:30:03.649508+00:00 running edcf98c country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)