Hide "Load More" link when no more posts to load
<p>This is a follow up on my previous post, now with different code.</p>

<p>I got this working, it loads the content I want, all the pages (see <a href="http://stackoverflow.com/questions/9990197/jquery-load-content-return-no-more-than-current-next-page-i-want-more-pages-t">previous post</a>). I have 9 pages (standard WP archive where I use next_posts_link as "anchor" for the click.</p>

<p>But when page 9 is load, I click "Load More" and it keeps loading page 9....I want it to stop and hide the "load more" link. Any help much appreciated.</p>

<pre><code>jQuery(document).ready(function($) {
var $content = '#upplevelser';
var $nav_wrap = '.navigation';
var $anchor = '.navigation .nav-previous a';
var $text = 'Load More';
var $next_href = $($anchor).attr('href'); // Get URL for the next set of posts
$($nav_wrap).html('&lt;a id="nav-below" href="' + $next_href + '"&gt;' + $text + '&lt;/a&gt;');
$('#nav-below a').click(function(e) {
    e.preventDefault();

if(jQuery(this).attr("href") == "") {
    alert('I am empty href value');
    }

    $.get($(this).attr('href'), '', function(data) {
    var $timestamp = new Date().getTime();
    var $new_content = $($content, data).wrapInner('&lt;div class="more-articles-here" id="rtz-' + $timestamp + '" /&gt;').html(); // Grab just the content
    $next_href = $($anchor, data).attr('href'); // Get the new href
    $($nav_wrap).before($new_content); // Append the new content
    $('#rtz-' + $timestamp).hide().fadeIn('slow'); // Animate load
    $('#nav-below a').attr('href', $next_href); // Change the next URL
    $('.more-articles-here ' + $nav_wrap).remove(); // Remove the original navigation

    });
});
});
</code></pre>
