Learner
Learner

Reputation: 786

Execute Jquery on linkbutton click

I want to execute the following jquery function

$(document).ready(function () {
    $('.btnReset').click(function () {
        $('#txtFirstName').val('');
    });
});

The error is:

uncaught ReferenceError: $ is not defined.

on link button click, which is as follows;

<asp:LinkButton ID="btnReset" CssClass="btnReset" runat="server">RESET</asp:LinkButton>

But, I don't know why it is not working, Please assist me if anybody knows that. Thanks.

Upvotes: 0

Views: 92

Answers (1)

Ehsan Sajjad
Ehsan Sajjad

Reputation: 62498

asp.net changes Ids when rendering server side controls on client side, so i suspect that textbox value is not changed because of this so do like this:

$(document).ready(function () {
    $('.btnReset').click(function () {
        $("#<%=txtFirstName.ClientID%>").val('');
    });
});

Upvotes: 2

Related Questions