Jquery Parents

JQuery Find, Parents, and Siblings by Eric on February 1, 2020

A very important tool when working with JQuery is the ability to traverse through elements in the DOM.  When a user clicks on a button you may want to change the color of the nearest row to display the click.  Maybe after an input you want to change the nearest column to be hidden or show that input value.  Whenever you need to walk through the elements in your page JQuery has a way to do it.  All of the methods shown here can be called with no arguments but are more helpful if you call them with a selector of some kind either an id, class, or element type. The first question you have to ask yourself is where is the element I'm looking for from my current location?  For instance, that button that was clicked is on a row.  The row element contains the button so we need to travel upwards.  When traveling up you can do one of two things, $.parent() or $.parents().  The difference between the two is that the latter travels more than just a single level in the DOM.  Obviously that makes...