HTML is
<tr>
<td><input /></td>
<td><a>ref</a></td>
</tr>
I got$('a')
What is the most optimal way to get <input />
from this ?
If they are together <input /><a></a>
, i can use $('a').sibling('input')
, but they are in different td's
Try this:
$('a').parent().prev().children('input')
You can do this:
$('a').closest('td').siblings().find('input')
This goes up to the <td>
, and searches siblings for <input>
elements.
Another variation
var input = $('a').closest('tr').find('td input');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With