2012-07-25 6 views

답변

0

는 다음과 같은 시도 : live()이되지 않습니다

$('option:not(:selected)', this).each(function(){ 
    // ... 
}) 

하는 것으로, 대신 on()를 사용할 수 있습니다.

1

이렇게하려면 this + ' ...'을 사용할 수 없습니다. this은 DOM 요소입니다. 대신, find를 사용

$(this).find('option:not(:selected)').each(function(){ ... 

(당신의 선택은, option:not(option:selected) 당신이하지 option 비트를 반복을 수행하여 괜찮다고, 아무 효과가 없습니다, 따라서 위.)

+0

children()은 더 좋을 것입니다. – bugwheels94

+2

@AnkitGautam : 어느 쪽이든 상관 없어요. 실제로, 옵션 그룹은 [optgroup] 요소 내에있을 수 있습니다. (http://www.w3.org/TR/html5/the-optgroup-element.html#the-optgroup-element) ,이 경우'어린이 '는 실패하지만'발견'이 효과가있다. –

0
$("option:not(:selected)", this).detach(); 

.each, .detach은 모든 요소에서 작동 할 필요가 없습니다.

관련 문제