首页javascriptchildren_indexjQuery Selector - 如何nth-last-child(2); 选择倒数第二个元素

jQuery Selector - 如何nth-last-child(2); 选择倒数第二个元素

我们想知道如何nth-last-child(2); 选择倒数第二个元素。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div:nth-last-child(2) {
  color: red;
}
</style>
</head>
<body>
  <div class="my_div">a</div>
  <div class="my_div">b</div>
  <div class="my_div">c</div>
  <div>other</div>
</body>
</html>