JQuery access label control and set value

JQuery access label control and set value

JQuery access label control and set value.

Text method of JQuery is used to set value of label control in html. Let’s see how to access label control by it’s ID and set value. In previous example we saw how to set value of input textbox using val() function. Here we need text() function to assign value to label control.

Jquery Set value of label control.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

  <script type="text/javascript" language="javascript">
  $(document).ready( function (){ 
      $("#submit").click( function(){
         var inputValue =   "This is value in label control.";
          $("#lblMessage").text( inputValue  );

Html element

           <label id="lblMessage"></label>
           <input id="submit" type="button" value="button" />


To find any element by ID prefix # sign to client side ID of html element

Now, you can access properties of html element or object.


JQuery Set Value of Textbox or Label Control In Asp.netJquery Dropdown Selected ValueJQuery Hidden Field Set ValueAsp.net access html control textbox element value at code behindJquery Set Value Of Textbox.Gridview select emailJquery Gridview Dropdownlist Selected Change Enable Disable ControlsGet Selected Value From Dropdownlist [JQuery]Learning JqueryJQuery get Value Of TextareaHow to get Jquery selected option


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.