Get value of TextBox Using jQuery

Getting Value Of Textbox in Jquery

1. If the Text Box is HTML control
HTML
<input type="text" value="text value" id="txtvalue" />
<script>
            $(document).ready(function(){
                  var textvalue=$("#txtvalue").val();
                  alert(textvalue)
// Value of textbox will show on alert when page is load
            });
</script>

2. When Text Box is ASP dot NET control
<asp:TextBox runat="server" id="txtvalue" Text="text value" />
<script>
            $(document).ready(function(){
                  var textvalue=$("#<%=txtvalue.ClientID%>").val();
                  alert(textvalue)
// Value of textbox will show on alert when page is load
            });
</script>
to get value of text box using Jquery first we have to add Jquery file which is direct download from Jquey.com.
Don't forget to add jquery library in your file

0 Comments