I need to get the value of the previous and next input by click on a element styling as a button…
Example code:
<ul>
<li>
<input type="text">
</li>
</ul>
<ul>
<li class="li-inline">
<a class="btn" href="#">
<i class=""></i>
</a>
</li>
</ul>
<ul>
<li>
<input type="text">
</li>
</ul>
I try with next() and prev() jquery methods but have not achieved the expected results.
$("a").click(function() {
$(this).next(":input");
});
First you have to reach the parent
ulusingclosest()and then go to next or previousulusingnext()orprev()respectively and find input in the descendants usingfind()Live Demo