使用 jquery 获取锚点的值

Get the value of anchor using jquery

<div class="dataTables_paginate paging_simple_numbers" id="myTable_reports_view_paginate">
    <a class="paginate_button previous disabled" aria-controls="myTable_reports_view" data-dt-idx="0" tabindex="0" id="myTable_reports_view_previous">&lt;&lt;</a>
    <span>
        <a class="paginate_button current" aria-controls="myTable_reports_view" data-dt-idx="1" tabindex="0">1</a>
        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="2" tabindex="0">2</a>
        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="3" tabindex="0">3</a>
        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="4" tabindex="0">4</a>
        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="5" tabindex="0">5</a>
        <span class="ellipsis">…</span>
    <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="6" tabindex="0">33</a>
    </span>
    <a class="paginate_button next" aria-controls="myTable_reports_view" data-dt-idx="7" tabindex="0" id="myTable_reports_view_next">&gt;&gt;</a>
</div>

我的问题是如何使用 jquery 获得值 33。

$('.paginate_button').last().text()

看起来你已经更新了问题,这使得答案不正确,所以下面是我更新的答案。

$('#myTable_reports_view_paginate span > a.paginate_button').last().text()

使用:last selector , to avoid next use :not()

alert($('a.paginate_button:not(.next):last').text())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="dataTables_paginate paging_simple_numbers" id="myTable_reports_view_paginate">
  <a class="paginate_button previous disabled" aria-controls="myTable_reports_view" data-dt-idx="0" tabindex="0" id="myTable_reports_view_previous">&lt;&lt;</a>
  <span>
                        <a class="paginate_button current" aria-controls="myTable_reports_view" data-dt-idx="1" tabindex="0">1</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="2" tabindex="0">2</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="3" tabindex="0">3</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="4" tabindex="0">4</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="5" tabindex="0">5</a>
                        <span class="ellipsis">…</span>
  <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="6" tabindex="0">33</a>
  </span>
  <a class="paginate_button next" aria-controls="myTable_reports_view" data-dt-idx="7" tabindex="0" id="myTable_reports_view_next">&gt;&gt;</a>
</div>

您还可以使用 last()not()

alert($('a.paginate_button').not('.next').last().text())
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="dataTables_paginate paging_simple_numbers" id="myTable_reports_view_paginate">
  <a class="paginate_button previous disabled" aria-controls="myTable_reports_view" data-dt-idx="0" tabindex="0" id="myTable_reports_view_previous">&lt;&lt;</a>
  <span>
                        <a class="paginate_button current" aria-controls="myTable_reports_view" data-dt-idx="1" tabindex="0">1</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="2" tabindex="0">2</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="3" tabindex="0">3</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="4" tabindex="0">4</a>
                        <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="5" tabindex="0">5</a>
                        <span class="ellipsis">…</span>
  <a class="paginate_button " aria-controls="myTable_reports_view" data-dt-idx="6" tabindex="0">33</a>
  </span>
  <a class="paginate_button next" aria-controls="myTable_reports_view" data-dt-idx="7" tabindex="0" id="myTable_reports_view_next">&gt;&gt;</a>
</div>

Try this
$('.paginate_button:contains("33")').text()