It's a very simple question, but I dont know exactly how to get from .
<div>
<input>
</div>
<p id="pepe"></p>
The following :
$("#pepe").prev()
gives me the div, how I get the first child (input)
It's a very simple question, but I dont know exactly how to get from .
<div>
<input>
</div>
<p id="pepe"></p>
The following :
$("#pepe").prev()
gives me the div, how I get the first child (input)
As you've seen prev()
gets the previous sibling element. To get the input
from there you need to use find()
, along with :first
assuming there will be multiple within your actual working HTML:
$("#pepe").prev().find('input:first');
$("#pepe").prev()
is getting you the <div>
try $("#pepe").prev().children('input');
In your code .prev()
point out the div element not the input. if you have search input means use .find()
in jquery
$("#pepe").prev().find('input')