John Smith
John Smith

Reputation: 6259

Get href from <a> in <li>

I try to get the correct href from an element :

<ul class="pagination pagination-sm center">
    <li class="prev disabled">
        <span> … </span>
    </li>
    <li class="active">
        <span> … </span>
    </li>
    <li class="next">
        <a href="/patients/79799?_=1386477592765&page=2" rel="next"> … </a>
    </li>
</ul>

I try to get the fref from the a tag thats parent is li class next:

$.getScript($('.pagination .next').attr('href'))

I get some output but somehow it never shows the page params! For eg my code triggers:

[06:00:16.759] GET http://localhost:3000/patients/79799?_=1386477659392 [HTTP/1.1 200 OK  672ms]

Is there another, better way to get the url without any errors?

Upvotes: 0

Views: 112

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388396

The href is specified in the anchor element within .next element, so you need to find the anchor element first

('.pagination .next a').attr('href')

Upvotes: 2

Related Questions