<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"><<</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">>></a>
</div>
My question is how to get the value 33 using jquery.
$('.paginate_button').last().text()
looks like you have updated the question, which makes the answer incorrect, so below is my updated answer.
$('#myTable_reports_view_paginate span > a.paginate_button').last().text()
Use :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"><<</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">>></a>
</div>
You can also use last() and 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"><<</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">>></a>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With