반응형
가장 가까운 일치하는 요소를 찾는 쿼리
열이 있는 일련의 행이 있고 다음의 값을 선택합니다.input
에 대한 이전 열에 있는 필드input
키가 해제될 때 함수를 호출하는 필드(가격 입력).
시도해 본 결과:
quantity = $(this).parent().parent().children().val() ;
quantity = $(this).parent().parent().children().closest('.inputQty', this).val() ;
하지만 둘 다 작동하지 않습니다.
DOM의 예:
<div class="row">
<div class="column"><input class="inputQty" id="quantity0" /></div>
<div class="column"><input class="someOther" id="Other0" /></div>
<div class="column">
<div class="cSelect">
<select id="currency0"><option>£</option></select>
<input class="price" id="price0" />
</div>
</div>
</div>
var otherInput = $(this).closest('.row').find('.inputQty');
행 수준까지 올라갔다가 다시 아래로 내려갑니다..inputQty
.
closest()
부모님만 찾으시거든요, 정말 원하시는 건
$(this).closest('.row').children('.column').find('.inputQty').val();
겟 더.column
의 부모this
요소, 이전 형제를 가져온 다음 입력을 찾으십시오.
$(this).closest(".column").prev().find("input:first").val();
데모: http://jsfiddle.net/aWhtP/
다음을 시도해 볼 수 있습니다.
$(this).closest(".column").prev().find(".inputQty").val();
언급URL : https://stackoverflow.com/questions/11756529/jquery-find-nearest-matching-element
반응형
'programing' 카테고리의 다른 글
python openpyxl 패키지에서 iter_rows()를 사용하는 방법은 무엇입니까? (0) | 2023.09.20 |
---|---|
JPA 최대 절전 모드 - 데이터베이스와 주석 모두에서 캐스케이드 삭제 (0) | 2023.09.20 |
Jquery에서 인덱스별로 하위 요소를 얻는 방법은? (0) | 2023.09.20 |
TSQL 문의 유효성을 프로그래밍 방식으로 확인(파싱)하려면 어떻게 해야 합니까? (0) | 2023.09.20 |
C에서 128비트 정수 할당 (0) | 2023.09.20 |