title: using jquery setInterval with delegate or on function
body: <p>I am trying to make a dynamic sample object for a card generator.
  the goal here is using a jquery color picker inside an asp.net update panel to pick a color and the chosen color will appear on the card frame (a <b><code>&lt;div&gt;</code></b> object).<br/>
  as I read in several posts, the only way to keep the refresh dynamic is by using a setInterval timer each 100 to update the color selected in the color picker, since the picker passes the color to a textbox, then the setInterval reads the info and updates the color of the card.<br>
  this is the code, which works fine:</p>
  
  <pre><code>$(document).ready(function () {
          setInterval(function () {
              var cant = $('input[id$="txtColorFuente"]').val().length;
              if (cant &gt;= 6) {
                  $('div[id$="divMarco"]').css("color", "#" + $('input[id$="txtColorFuente"]').val());
              }
              cant = $('input[id$="txtColorFondo"]').val().length;
              if (cant &gt;= 6) {
                  $('div[id$="divMarco"]').css("background-color", "#" + $('input[id$="txtColorFondo"]').val());
              }
          }, 100);
      });
  </code></pre>
  
  <p>The DOM goes like this:<br></p>
  
  <pre><code>MasterPage,
  Body,
  Content(inner page),
  &lt;asp:UpdatePanel runat="server" ID="updatePanel1" UpdateMode="Conditional"&gt;
  &lt;ContentTemplate&gt;
          &lt;section class="AdminFormLeft"&gt;
              &lt;asp:Label ID="lblResult" CssClass="message-error" runat="server" Text=""&gt;&lt;/asp:Label&gt;
              &lt;ul&gt;
                  &lt;li class="labelForm"&gt;Color de fondo&lt;br /&gt;
                      &lt;asp:TextBox ID="txtColorFondo" MaxLength="6" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;/li&gt;
                  &lt;li class="labelForm"&gt;Color de fuente&lt;br /&gt;
                      &lt;asp:TextBox ID="txtColorFuente" MaxLength="6" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&lt;/li&gt;
  
              &lt;/ul&gt;
          &lt;/section&gt;
      &lt;/ContentTemplate&gt;
      &lt;Triggers&gt;
          //My triggers here
      &lt;/Triggers&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>This works fine, until the update panel refreshes, then is lost, because it's re-generated, so I have to use delegate() or on() functions, however all my tries has been in vain. ¿How can I implement delegates or on function on set interval function above? thanks!</p>