Home >Web Front-end >JS Tutorial >The difference between finding parents and closest methods in jquery_jquery
1. Return value The former can return multiple elements or can only return 0 or 1
2. The stopping time is different. The former is all the superior elements, that is, all the way to the root, which is usually the body. The latter is until it is found, and it stops when it finds one
3. The starting elements are different. The former starts from the parent element and the latter starts from itself
The code is as follows:
Add border to ancestors