2010-06-02 6 views
0

중첩 된 div가있는 div 상자가 많은데 .title 버튼이 안에 있습니다. jQuery에서 단추의 부모를 선택하는 방법이 있습니까? 같은jQuery 선택기 : this.parent, 그런 것이 있습니까?

뭔가 :

$("#button").click(function(){  
     $("this.parent").css({'border-bottom' : 'none'}); 
     }); 

또는 나는 독특한 클래스에 내 타이틀의 모든 클래스를 이름을 변경해야 할 것입니까?

+2

아니 선택기 방법. 선별자는 항상 아래쪽이 아닌 위쪽으로 향합니다. – Guffa

+0

방법은 내가 의미했던 것입니다. 맹세코 ... 감사합니다. – Kyle

답변

6

가 (그 버튼에 대한 이벤트 처리기 내부)이 소용돌이 보내기

$(this).parent().css({'border-bottom' : 'none'}); 
+0

@GlenCrawford 당신은 거기에 여분이 있습니다. " – ant

+0

@ c0mrade : 버그 = 중화 – GlenCrawford

+0

@GlenCrawford 긍정 : – ant

6

이 시도 :

$("#button").click(function(){  
     $(this).parent().css({'border-bottom' : 'none'}); 
     }); 

또는 $(this).parent("div").css({'border-bottom' : 'none'});

1

jQuery.parent()

$(function(){ 
    $("div.title a").click(function(){ 
    $(this).parent().css("background-color", "red"); 
    return false; 
    }); 
});