There are different ways to make it shorter, but one possible solution is to use the .closest()
method to find the closest ancestor element that matches a selector, and then use the .find()
method to get the descendant element(s). Here's an example:
index.tsx55 chars2 lines
Replace .parent-class
with the actual class name or selector of the closest ancestor element that contains the link you want to click. This should be more efficient than chaining multiple .parent()
methods.
gistlibby LogSnag