title: Dynamically created dropdown giving error on calling a method
body: <p>This is my code, so basically on click of button I want to call this method addpoc() which creates a block of input boxes and a dropdown. I want to call a method showmail() on selection of dropdown option but it throws error. How can i fix it ?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>  function addpoc() { 
                  let el;
                  el += '&lt;div class="clearfix"&gt;&lt;div class="name"&gt;&lt;label for="fname"&gt;First name:&lt;/label&gt;&lt;br&gt;&lt;input type="text" id="fname" name="fname" placeholder="Ricky"&gt;&lt;/div&gt;&lt;div class="name"&gt;&lt;label for="lname"&gt;Last name:&lt;/label&gt;&lt;br&gt;&lt;input type="text" id="lname" name="lname" placeholder="Ju"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="parent" style="width: 100%;"&gt;&lt;div id="one"&gt;&lt;select id="contact method" onchange="'+ showMail() +'"&gt;&lt;option value="workmail" selected&gt;Work email &lt;/option&gt;&lt;option value="personalmail"&gt;Personal Email&lt;/option&gt;&lt;/select&gt;&lt;/div&gt;&lt;div id="two" style="display: none;"&gt;&lt;input type="email" name="email" placeholder="Work email"&gt;&lt;/div&gt;&lt;div id="three" style="display: none;"&gt;&lt;input type="email" name="email" placeholder="Personal email"&gt;&lt;/div&gt;&lt;/div&gt;'
  
                  $('#addelement').append(el);
              }
              
              
                function showMail() {
                  let selecteop = document.getElementById("contact method");
                  if (selecteop.value == "workmail") {
  
                      $("#two").show();
                      $("#three").hide();
                  }
                  else {
                      $("#three").show();
                      $("#two").hide();
                  }
              }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div&gt;
                  &lt;div id="addelement"&gt;&lt;/div&gt;
                  &lt;button id="addbtn" onclick="addpoc()"&gt;Add another point of contact&lt;/button&gt;
             
              &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>