Making span clickable after prepend in jQuery
<p>I have a DIV where some code is presented. When I hover on this DIV I want to present a button that toggles the comments inside the code block. So far I have this:</p>

<pre><code>$('.code-block').hover(
    function(){
        $(this).prepend('&lt;span class="code-block-control"&gt;toggle comments&lt;/span&gt;');
    },
    function(){
        $('.code-block-control',this).remove();
    }
);

$('.code-block-control').click( function(){ $('.comment').toggle(); } );
</code></pre>

<p>The span is presented when I hover over the code block. But when I click the span that is created nothing happens. Even if I change the click function to a simple alert nothing happens.</p>

<p>Anyone have any idea on how to fix this.</p>
