2011-12-10 4 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

関連する問題