Questions tagged [closest]

Closest is being the nearest to a number, object, quantity etc.

Given a number of objects, the closest 2 objects would be those that the between them is the shortest.

561 questions
12
votes
2 answers

jQuery find closest parent link with attribute

I'd like to find the closest link with attribute findme from a children .startpoint. Structure:
dude
  • 5,678
  • 11
  • 54
  • 81
11
votes
3 answers

Can I create a selector with multiple elements using Jquery closest()

I have a listener for click events from which I need to exclude some elements. Right now my list is growing, so I'm looking for a better way to "bundle" multiple elements in a selector. This is what I have: $(document).on('click tap',…
frequent
  • 27,643
  • 59
  • 181
  • 333
11
votes
2 answers

JQuery find() opposite

I want to find the next form-element, starting from input-object inside. Find() is a great function to find child objects. But what about the opposite Way to find in parent?
dazzafact
  • 2,570
  • 3
  • 30
  • 49
10
votes
2 answers

using jquery, how would i find the closest match in an array, to a specified number

using jquery, how would i find the closest match in an array, to a specified number For example, you've got an array like this: 1, 3, 8, 10, 13, ... What number is closest to 4? 4 would return 3 2 would return 3 5 would return 3 6 would return 8 ive…
brent white
  • 103
  • 1
  • 1
  • 4
10
votes
6 answers

jQuery data attribute selector for closest parent

My code have data attribute set for many elements (Not For All Elements) in below manner.
And, for some of the elements (Not For All Elements) data attribute is set with below…
DevD
  • 155
  • 1
  • 1
  • 9
10
votes
3 answers

Fastest way to find the closest point to a given point in 3D, in Python

So lets say I have 10,000 points in A and 10,000 points in B and want to find out the closest point in A for every B point. Currently, I simply loop through every point in B and A to find which one is closest in distance. ie. B = [(.5, 1, 1), (1,…
Saebin
  • 404
  • 6
  • 14
10
votes
2 answers

jQuery $.closest() (Or whichever comes first)

While working a project tonight, I ended up using one .js resource file for two different pages. One page contains a textarea within a div, and another contains a textarea within a td. Wanting to work with the siblings of this textarea, and other…
Sampson
  • 265,109
  • 74
  • 539
  • 565
8
votes
1 answer

jQuery find nearest

I needed to find the nearest element, relative to another element. I wanted a generic function not locked to a spesific tree structure. Maybe it already exists within jQuery and if so please show me! Here is what I came up with and it works for what…
Christian
  • 81
  • 1
  • 2
8
votes
4 answers

How would I go about finding the closest date to a specified date? (Java)

I was hoping to know how I would type up a method to give me the closest date to a specified date. What I mean is something along the following: public Date getNearestDate(List dates, Date currentDate) { return closestDate // The date…
Dylan Wheeler
  • 6,928
  • 14
  • 56
  • 80
8
votes
3 answers

.closest() in Capybara

I'd like to find closest parent of an html element in cucumber. just like the .closest() function of jQuery does. this is my (pseudo) code: aspect = find('.dropdown li:contains('+selector+')') dropdown = aspect.closest('.dropdown') #<-- the…
manuels
  • 1,511
  • 3
  • 14
  • 26
8
votes
1 answer

jquery: closest('h3') selector?

i have:

    Like this

  • 2
this is my jquery code $('.iLikeThis…
matt
  • 42,713
  • 103
  • 264
  • 397
8
votes
5 answers

Return closest date to a given date in R

My data frame consists of individual observations of individual animals. Each animal has a birthdate, that I would like to associate to the closest field season date from a date vector. Here is a very basic reproducible example: ID <- c("a", "b",…
Mehdi.K
  • 371
  • 4
  • 15
8
votes
3 answers

Using the Jquery closest() function?

Here's my HTML: click here This is what I'd like to display And I have currently got this JQuery code, $(document).ready(function(){ $(".r3c").hide(); …
Nick
  • 1,233
  • 13
  • 26
  • 37
7
votes
3 answers

Nokogiri equivalent of jQuery closest() method for finding first matching ancestor in tree

jQuery has a lovely if somewhat misnamed method called closest() that walks up the DOM tree looking for a matching element. For example, if I've got this HTML:
Yay
Assuming element is set to…
lambshaanxy
  • 22,552
  • 10
  • 68
  • 92
7
votes
1 answer

Closest-match string-array sorting in Swift

Using Swift4, I would like to sort a string-array according to the closest match to a given searchTerm. Important is to me that if the searchTerm can be found as an exact-match, then the returnArray should show this searchTerm upfront ! Example:…
iKK
  • 6,394
  • 10
  • 58
  • 131
1
2
3
37 38