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
5
votes
2 answers

why js closest method not find sibling element?

Note: as far as i know that closest() method searches up the DOM tree for the closest element which matches a specified CSS selector. When i click on margin space between two li element .. it's return null... but if i replace margin-bottom: 15px;…
نور
  • 1,425
  • 2
  • 22
  • 38
5
votes
2 answers

Identifying closest value in a column for each filter using Pandas

I have a data frame with categories and values. I need to find the value in each category closest to a value. I think I'm close but I can't really get the right output when applying the results of argsort to the original dataframe. For example, if…
Scott Chamberlin
  • 724
  • 2
  • 8
  • 23
5
votes
3 answers

Jquery Closest From Element Value

Im trying to get a form element value using closest. Here some example code.
Hour Minute
Lee
  • 20,034
  • 23
  • 75
  • 102
5
votes
4 answers

Find closest sibling using jQuery

Given the following DOM
We need to find the closest
  • -Element with data-id="1" to the one with data-id="3" We…
  • Raphael Jeger
    • 5,024
    • 13
    • 48
    • 79
    5
    votes
    2 answers

    jQuery closest div with specific class/id

    I need your help. This code works fine for me:
    Heiko M.
    • 53
    • 1
    • 1
    • 3
    5
    votes
    2 answers

    jquery parents/closest not working

    I have a link which posts some data to a controller. It is working fine and updates the data. But I want to change the css of the parent div but it is not happening. I have tried a lot of variations but I must be doing something stupid. The code is…
    Tripping
    • 919
    • 4
    • 18
    • 36
    5
    votes
    2 answers

    jQuery .closest() returns multiple results within a custom jQuery plugin

    While hacking my free-time project I stumbled upon a puzzling jQuery behaviour. I have a custom validation plugin written and working. In the plugin I wanted to implement some functionality using .closest() method. Strangely enough this method…
    koniczynek
    • 103
    • 1
    • 7
    4
    votes
    1 answer

    jQuery a solution between children() and find(): anything that looks like closest()?

    Based on the different answers received, the only solution using jQuery without implementing our own selector function is a basic selector with ":first" or followed by ".eq(0)" for jQuery. I wanted to know if their were any kind of max depth option…
    Micaël Félix
    • 2,697
    • 5
    • 34
    • 46
    4
    votes
    3 answers

    jQuery Closest() isn't working

    Could someone please explain me why replacing the following $('.post_title a').hover(function () { $(this).parent().parent().parent().parent().find(".post_footer").toggleClass('footer_border') }); with $('.post_title a').hover(function () { …
    Xtatic Uforia
    • 99
    • 1
    • 1
    • 7
    4
    votes
    6 answers

    perl regex match closest

    I'm trying to match from the last item closet to a final word. For instance, closest b to dog "abcbdog" Should be "bdog" But instead I'm getting "bcbdog" How can I only match from the last occurrence "b" before "dog" Here is my current regex:…
    srchulo
    • 5,143
    • 4
    • 43
    • 72
    4
    votes
    2 answers

    Merge two dataframes by a closest value in R

    I have two dataframes that I want to merge by the closest value in one column. The first dataframe (DF1) consists of individuals and their estimated individual risk ("risk"): DF1<- data.frame(ID = c(1, 2, 3), risk = c(22, 40, 20)) ID risk 1 …
    4
    votes
    5 answers

    jquery closest doesn't want to work

    I have repeated down the page an image with a div next to it like this:

    this is where text for the text will…

    phili
    • 385
    • 2
    • 5
    • 11
    4
    votes
    4 answers

    Select specific closest element

    I have the following html :
    link
    magda
    • 43
    • 1
    • 1
    • 3
    4
    votes
    1 answer

    Why cannot I select the next DIV sibling using pure JavaScript?

    I have two div elements with one button in the first div as follows.
    Below is my JavaScript…
    O Connor
    • 4,236
    • 15
    • 50
    • 91
    4
    votes
    6 answers

    Find the closest value in a matrix matlab

    How can I find the closest element in a matrix in matlab? Suppose I have a matrix of the size 300x200 and I want to find the value and the index of the element in the matrix which is the closest to a element given. Does anyone know how this can be…
    user3366536
    • 151
    • 1
    • 2
    • 7