Estoy tratando de obtener la etiqueta a a continuación para tomar el valor de la selección y pegarlo en la entrada.use JQuery para obtener hermanos
<td class="ms-formbody" style="width:385px">
<input name="ctl00$PlaceHolderMain$dlFields$ctl00$txtSource" type="text" id="ctl00_PlaceHolderMain_dlFields_ctl00_txtSource" class="ms-input" />
<select name="ctl00$PlaceHolderMain$dlFields$ctl00$ddlSourceFields" id="ctl00_PlaceHolderMain_dlFields_ctl00_ddlSourceFields" class="ms-input">
<option value="Some Field Name 1">Some Field Name 1</option>
<option value="Some Field Name 2">Some Field Name 2</option>
<option value="Some Field Name 3">Some Field Name 3</option>
<option value="Some Field Name 4">Some Field Name 4</option>
</select>
<a href="javascript: appendField();">append</a>
</td>
Parece que no sé cómo agarrar a los hermanos. Intenté $(this).siblings("input").val()
pero ese error erró el Webpage 'parentNode.firstChild' is null or not an object
.
Probado $(this).prev().prev().val()
y que vuelve indefinido. ¿Cuál es la mejor manera de agarrar estas cosas?
Gracias, David
Gracias por su ayuda, esto fue realmente útil.Siguiendo su ejemplo, envolví mi tabe con un div y luego lo agarré y funcionó maravillosamente $ (document) .ready (function() { $ ("# myList a"). Click (function() { var $ selectValue = $ (this) .siblings ("select"). val(); var $ thatInput = $ (this) .siblings ("input"); $ thatInput.val ($ selectValue); }) }); –
Me alegro de haber ayudado –