首页javascriptrelationjQuery Selector - 如何选择父母和孙子

jQuery Selector - 如何选择父母和孙子

我们想知道如何选择父母和孙子。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
$(function(){
    $('.jstree a:not(:eq(1))').css('background', 'yellow');
});
</script>
</head>
<body>
  <div class="jstree">
    <ul>
      <li><a>PARENT</a>
        <ul>
          <li><a>CHILD</a>
            <ul>
              <li><a>GRANDCHILD</a></li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </div>
</body>
</html>