title: How to retrieve dynamically created html element data with jquery
body: <p>I am new to JQuery and web development. I am developing a dynamic web application. I am using html and JQuery on front-end, communicating with server side via servlets. I create many question pages where questions retrieved from database and inserted into a single html file. So each page contains one question which is dynamically created. I need to get the answers selected from the input elements which could be radio, checkbox, text, slider. The problem is, I want the answers in the same order of questions. I am planning to store them in a var separating with ";" and pass it to server-side via servlet and then store. How can I get selected values with JQuery when next button is clicked?
  Thanks in advance for the help.</p>
  
  <p>Here is a sample generated question code:</p>
  
  <pre><code>&lt;div data-role="page" id="question1"&gt;
      &lt;div data-role="header"&gt;
          &lt;h1&gt;Header&lt;/h1&gt;
      &lt;/div&gt;
  &lt;div data-role="content"&gt;
          &lt;div data-role="fieldcontain"&gt;
          &lt;fieldset data-role="controlgroup" data-type="horizontal"&gt;
                  &lt;legend&gt;Gender:&lt;/legend&gt;
                  &lt;input type="radio" name="singleSelection" id="choice1"&gt;
                  &lt;label for="choice1"&gt;Male&lt;/label&gt;
                  &lt;input type="radio" name="singleSelection" id="choice2"&gt;
                  &lt;label for="choice2"&gt;Female&lt;/label&gt;
          &lt;/fieldset&gt;
          &lt;fieldset class="ui-grid-a"&gt;
              &lt;div class="ui-block-a"&gt;&lt;input type="button" value="Next" data-theme="b"&gt;&lt;/div&gt;
          &lt;/fieldset&gt;
          &lt;/div&gt;  
      &lt;/div&gt;
     &lt;/div&gt;
  
  &lt;div data-role="page" id="question2"&gt;
      &lt;div data-role="header"&gt;
          &lt;h1&gt;Header&lt;/h1&gt;
      &lt;/div&gt;
  &lt;div data-role="content"&gt;
       &lt;fieldset data-role="controlgroup"&gt;
          &lt;legend&gt;What are your hobbies?&lt;/legend&gt;  
          &lt;input type="checkbox" name="multiSelection0" id="multiSelection0"&gt; 
          &lt;label for="multiSelection0"&gt;Cinema&lt;/label&gt;  
          &lt;input type="checkbox" name="multiSelection1" id="multiSelection1"&gt; 
          &lt;label for="multiSelection1"&gt;Football&lt;/label&gt;  
          &lt;input type="checkbox" name="multiSelection2" id="multiSelection2"&gt;
          &lt;label for="multiSelection2"&gt;Basketball&lt;/label&gt;  
       &lt;/fieldset&gt; 
       &lt;fieldset class="ui-grid-a"&gt;
             &lt;div class="ui-block-a"&gt;&lt;input type="button" value="Next" data-theme="b"&gt;&lt;/div&gt;
       &lt;/fieldset&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>