The script below adds items to an array when you click the link, and generates a list of items as html output. You can see an example here: http://jsfiddle.net/dqFpr/
I am trying to create a function to delete items from the list. Not a difficult task with splice(), but somehow clicking the delete link doesn't trigger the test_function() function.
Can someone tell me what I am doing wrong, or show me another way of triggering the function? Your help is really appreciated ;-)
<script language="javascript">
    $(document).ready(function() {
        function test_function( number ) {
            /* This function is not triggered, nothing works inside here!! */
        }
    });
    var lines = [];
    function update_list( lines ) {
        var thecode = '';
        for(var i = 0; i < lines.length; i++) {
            thecode = thecode + lines[i] + ' <a onclick="javascript:test_function('+i+')" href="#">(delete)</a><br />';
        }
        $('div#display').html(thecode);
    }
    $('a#new').click(function() {
        lines.push('another line');
        update_list(lines); 
    });
</script>
<div id="display"></div>
<a href="#" id="new">Add a new line</a>
 
     
    