Span content clear the button beneath the span element
<p>The body of the html has a <code>span</code> element and a <code>button</code> after it. The button click event should clear the span element and any key press should prepend the event key code to the span element. I'm using jQuery version 1.9.1.</p>

<p>What happens is, the <code>empty()</code> clears the span text <em>and</em> the button that is present after the span element as well. Kindly let me know what went wrong here.</p>

<pre><code>function appendtext(event) 
{ 
    var keyCode = event.keyCode; 
    $("#spanid").prepend(keyCode); 
} 

$(document).keyup(appendtext); 

function clearfn() 
{ 
    ("#spanid").empty();
} 
</code></pre>
