Adding click event to on the fly generated input

Adding click event to on the fly generated input

Hello

I'm trying to add an event to a 'on the fly' generated input radio buttons. I've tried several ways (commented) but none works.
What i m doing wrong?
as i m not a coder at all, is my code can be improved?

  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3.     <!--<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"
  4. type="text/javascript" charset="utf-8"></script>-->
  5.     <script type="text/javascript" src="jquery.min.js"></script>
  6.     <script type="text/javascript">
  7.         addQuestions('000','#questions');      
  8. <!--this don't work
  9. $('div#questions').click(
  10.             function(e){
  11.                 if ($(e.target).is('input[value="Yes"]')) {
  12.                     addQuestions($(this).attr('id'), 'Q_' + $(this).attr('id'))
  13.                 }
  14.             });
  15. -->
  16.         function addQuestions(questionParent, parentElementId){
  17.             $.ajax({
  18.                 type: 'GET',
  19.                 url: 'questions.xml',
  20.                 dataType: 'xml',
  21.                 success: function(xml){
  22.                     $(xml).find('question').each(function(){
  23.                         if ($(this).find('parent').text() === questionParent){
  24.                             var id = $(this).attr('id');
  25.                             var question = $('<p />').append('Q'+ id + ': ' + $(this).find('entitled').text());
  26.                             var tooltip = $(this).find('text').text();
  27.                             var questionElement = $('<div />');
  28.                             questionElement
  29.                                 .attr('id','Q_' + id)
  30.                                 .addClass("question")
  31. <!-- this don't work also
  32. .click(function(){addQuestions($(this).attr('id'), 'Q_' + $(this).attr('id'))})
  33. -->
  34.                                 .append(question)
  35.                                 .append(radioButton(id, 'Yes', 'Oui'))
  36.                                 .append(radioLabel(id, 'Yes', 'Oui'))
  37.                                 .append(radioButton(id, 'No', 'Non', true))
  38.                                 .append(radioLabel(id, 'No', 'Non'))
  39.                                 .append(radioButton(id, 'Unknown', 'Je ne sais pas'))
  40.                                 .append(radioLabel(id,'Unknown', 'Je ne sais pas'));
  41.                             $(parentElementId).append(questionElement);
  42.                         }});},
  43.                 error: function(e){
  44.                     alert("erreur:" + e)
  45.                 }});}
  46.         function radioButton(radioId, radioValue, radioLabel, radioChecked){
  47. <!-- code to create radio button-->
  48.         }
  49.         function radioLabel(radioIdLb, radioValueLb,radioLabelLb){
  50. <!-- code to create label for radio button-->
  51.         }
        </script>
    </head>
    <body>
        <div id="questions">
        </div>
    </body>
    </html>