2011-12-31 3 views
2

내 웹 페이지에 끌어다 놓기 기능이 있습니다. 드래그 된 div에는 2 개의 input> hidden이 포함되어 있으며 다른 div에 드롭됩니다.jQuery UI에서 드래그 한 요소의 자식 요소를 얻는 방법

드롭 이벤트에서 변수의 input> hidden 값을 모두 가져 오려고합니다.

다음은 내 드래그 가능한 구조입니다.

내가 할

<div class="srcfield" title="Drag and map Last Name!"> 
<span><img src="images/cursor1.png" height="14" width="14" border="0"/>&nbsp;&nbsp;First Name</span> 
<input type="hidden" name="FieldName" value="FirstName"/> 
<input type="hidden" name="SourceType" value="B"/> 

는 :

ui.draggable.children("input").attr("name") 

그것은 내가 먼저 전용 필드를 숨겨 준다.

내가 두 번째 필드

감사 WK 모든

답변

3

먼저 숨겨진 얻을 수있는 방법, 당신의 HTML이 올바르지 않습니다.

두 번째로 ui.draggable.children("input")은 단일 요소가 아니며 .attr("name")은 값이 아닙니다. 당신이 값을 가져하려는 경우, 당신은 ui.draggable.children("input").attr("name")을 반복해야하고 예를 들어 .val()

를 사용

ui.draggable.children("input").each(function(){ 
    alert($(this).val()); 
}); 

당신은, 단지 특정 값을 얻을 입력에 클래스를 추가하고이를 해결하는 것이 좋습니다 경우 그 계급에 의해. 사용 된 기능에 대한 자세한 내용은 jQuery's docs

을 확인하십시오.
관련 문제