function to seemingly randomly ingnore lines
<p>I'm working on a html structure consisting of a <code>div</code> containing several <code>article</code> elements. On a button press, some jquery gets the content from a server for a new <code>article</code> element, substitutes this into a template, and appends this to the <code>div</code>.
Another function deletes all elements with class <code>deletenext</code> takes the top element, selected with <code>article:first</code> and adds the <code>deletenext</code> class to it- This class is hidden in css, but can be restored.</p>

<p>These are tied to a keypress.</p>

<p>The setup works perfectly without the AJAX part- I can scroll through the elements by calling the function from the console, or with the keypress. When I include just the AJAX section, that works perfectly too. </p>

<p>But when I use both called as <code>func1();func2</code>, either from the console or from keypress, I get problems- Normally the ajax only runs, and The div keeps getting longer, but occasionally, seemingly at random, the delete function will delete a few lines. Calling either function on its own, or alternatively from the console works fine, as long as Not in the same run. Order doesn't seem to matter, so it seems to not be a synchronisation problem(<code>scrollDown</code> is all synchronous functions, and it shouldn't matter)</p>

<p>Relevant Code shown below.</p>

<pre><code>function scrollDown(callbackck) {
    $('article.deletenext:first').remove();
    $('.content article:first').addClass("deletenext");
};
function scrollUp() {
    $('.content article.deletenext').removeClass("deletenext");
}
function loadNext() {
    $.getJSON('test.json', function (data) {
        $('.content').append("&lt;article&gt;&lt;h1&gt;" + data.title + "&lt;/h1&gt;&lt;section class='articlecontent'&gt;" + data.content + "&lt;section&gt;&lt;/article&gt;");
    });
};
$(document).bind('keydown', function(e) {
    if (e.keyCode == 75) {
        scrollUp();
    }
    else if (e.keyCode == 74) {
        scrollDown();
        loadNext();
    };
    return false;
});
</code></pre>
