HTML
<tr> <td><input /></td> <td><a>ref</a></td> </tr>
I got $('a')
$('a')
What is the best way to get <input /> from this?If they are <input /><a></a> together, I can use $('a').sibling('input') , but they are in different td
<input />
<input /><a></a>
$('a').sibling('input')
You can do it:
$('a').closest('td').siblings().find('input')
This matches the <td> value and searches for siblings for the <input> elements.
<td>
<input>
Another variation
var input = $('a').closest('tr').find('td input');
Try the following:
$('a').parent().prev().children('input')