ASP.NET – jQuery is not Working in UpdatePanels
<p>I am unable call jQuery functions within "asp:UpdatePanel". As per the code given below I want to add a class on div element ".popup-body" but its not working. On the other side "alert();" works.</p>

<p>My jQuery Code:</p>

<pre><code>$(document).ready(function () {
    $(".popup-body .btn").click(function () {
        //alert("it works");
        $(this).closest(".popup-body").addClass("loading-content");
    });
});
</code></pre>

<p>My HTML:</p>

<pre><code>    &lt;asp:UpdatePanel runat="server"&gt;
        &lt;ContentTemplate&gt;
            &lt;div class="testDiv"&gt;test div&lt;/div&gt;
            &lt;div class="popup-body" id="divBody" runat="server"&gt;
                &lt;div class="textbox"&gt;
                    &lt;label&gt;First Name:&lt;/label&gt;
                    &lt;asp:TextBox runat="server" ID="txtFname" /&gt;
                &lt;/div&gt;
                &lt;div class="footer"&gt;
                    &lt;asp:Button Text="Save" CssClass="btn" ID="btnSave" runat="server" /&gt;
                    &lt;asp:Button Text="Clear" CssClass="btn" runat="server" ID="btnClear" /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/ContentTemplate&gt;
    &lt;/asp:UpdatePanel&gt;
</code></pre>

<p>I have read many articles and tried different solutions like following, but failed</p>

<pre><code>// JavaScript funciton to call inside UpdatePanel
    function jScript() {
        $("#click").click(function () {
            alert("Clicked Me!");
        });
    }
//Code placed within "asp:updatepanel"
&lt;script type="text/javascript" language="javascript"&gt;
            Sys.Application.add_load(jScript);
&lt;/script&gt;
</code></pre>