Set TextBox value to Label using jQuery

Last Reply 2 months ago By pandeyism

Posted 2 months ago

i am getting the text value after clicking. It is showing in alert form But i want to store it in textbox or label

<script>
    $(document).ready(function () {
        $('.info').click(function () {
            alert($(this).text())
        });
    });
</script>

 

Posted 2 months ago

Hi v@run,

Refer below sample.

HTML

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.info').click(function () {
            $("#lblMessage").html($("#txtName").val());
            return false;
        });
    });
</script>
<div>
    Name :
    <asp:TextBox runat="server" ID="txtName" />
    <input type="button" name="Submit" value="Submit" class="info" />
    <asp:Button Text="Submit" CssClass="info" runat="server" />
    <asp:Label ID="lblMessage" runat="server" />
</div>

Screenshot