首页 新闻 会员 周边 捐助

关于Jquery中选择最接近的祖先元素的选择器的问题

0
[已解决问题] 解决于 2012-12-25 13:24
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Selected Shakespeare Plays</title>
   </head>
  <body>
    <div id="container">
      <h2>Selected Shakespeare Plays</h2>
      <ul id="selected-plays" class="clear-after">
        <li>Comedies
          <ul>
            <li><a href="/asyoulikeit/">As You Like It</a></li>
            <li>All's Well That Ends Well</li>
            <li>A Midsummer Night's Dream</li>
            <li>Twelfth Night</li>
          </ul>
        </li>
        <li>Tragedies
          <ul>
            <li><a href="hamlet.pdf">Hamlet</a></li>
            <li>Macbeth</li>
            <li>Romeo and Juliet</li>
          </ul>
        </li>
        <li>Histories
          <ul>
            <li>Henry IV (<a href="mailto:henryiv@king.co.uk">email</a>)
              <ul>
                <li>Part I</li>
                <li>Part II</li>
              </ul>
            </li>
            <li><a href="http://www.shakespeare.co.uk/henryv.htm">Henry V</a></li>
            <li>Richard II</li>
          </ul>
        </li>
      </ul>

      <h2>Shakespeare's Plays</h2>
      <table>
        <tr>
          <td>As You Like It</td>
          <td>Comedy</td>
          <td></td>
        </tr>
        <tr>
          <td>All's Well that Ends Well</td>
          <td>Comedy</td>
          <td>1601</td>
        </tr>
        <tr>
          <td>Hamlet</td>
          <td>Tragedy</td>
          <td>1604</td>
        </tr>
        <tr>
          <td>Macbeth</td>
          <td>Tragedy</td>
          <td>1606</td>
        </tr>
        <tr>
          <td>Romeo and Juliet</td>
          <td>Tragedy</td>
          <td>1595</td>
        </tr>
        <tr>
          <td>Henry IV, Part I</td>
          <td>History</td>
          <td>1596</td>
        </tr>
        <tr>
          <td>Henry V</td>
          <td>History</td>
          <td>1599</td>
        </tr>
      </table>
      <h2>Shakespeare's Sonnets</h2>
      <table>
        <tr>
          <td>The Fair Youth</td>
          <td>1–126</td>
        </tr>
        <tr>
          <td>The Dark Lady</td>
          <td>127–152</td>
        </tr>
        <tr>
          <td>The Rival Poet</td>
          <td>78–86</td>
        </tr>
      </table>
    </div>
  </body>
</html>

如此,怎么选择出与.pdf链接最接近的祖先元素<ul>

微澜的主页 微澜 | 初学一级 | 园豆:-1
提问于:2012-12-25 11:49
< >
分享
最佳答案
0
  var $partent = $('a[href$=".pdf"]').parents('ul:first');
奖励园豆:5
Qlin | 老鸟四级 |园豆:2403 | 2012-12-25 12:41
其他回答(1)
0

parent()

chenping2008 | 园豆:9836 (大侠五级) | 2012-12-25 13:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册