2011-12-10 3 views
0

나는 jQuery를의이 비트를 건너하고 나는 XPATH이 상황에서 무엇을 의미하는지 이해하는 데 실패하고있다 : 포함 된 요소를 찾고, 내가이 전에 보지 못한이 xPath는 무엇을 캡처하려고합니까?

var all_line_height = $(this).find("*[style*='line-height']"); 

(?) 스타일 속성의 선 높이?

나는 작은 테스트를 수행했고, 테스트를 수행하지 않았습니다.

+0

첫 번째 별표 방법에 의해 필요하지 않습니다. – pimvdb

답변

3

그건 XPath가 아닙니다. 이 셀렉터는 스타일 속성이 현재 선택된 요소 (this)의 line-height을 포함하는 요소를 선택합니다.

$(this)      // selects the current element 
     .find(...)   // Select all elements which match the selector: 
    *[style*='line-height'] // Any element (*), 
          // whose style attribute ([style]) 
          // contains "line-height" (*='line-height') 

다음과 같이 구현 될 수있다 :

// HTML: 
// <div id="test"> 
// <a style="line-height:10px;color:red;">... 

$("#test").click(function(){ 
    // this points to <div id="test"> 
    var all_line_height = $(this).find("*[style*='line-height']"); 
    alert(all_line_height.length); //Alerts 1 
}) 
+0

많은 감사드립니다! nooby 질문에 대한 사과. – Abs