[Solved] jQuery Find Closest Input


Closest will search for the parent elements. Here the input is not the parent element of the image. Its a sibling only. You can use siblings() selector for this purpose.

var input = $(image).siblings("input");

Or you can use,

var input = $(image).closest(".col-md-2").find("input");
  • Get the parent div(since the image and input are under same parent)
  • Then find the child input of that parent

solved jQuery Find Closest Input