WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES
Advertisements

How to Set the Value of Input Text Box using jQuery

Topic: JavaScript / jQueryPrev|Next

Answer: Use the jQuery val() Method

You can simply use the jQuery val() method to set the value of an input text box.

Try out the following example to see how it actually works:

  • <!DOCTYPE html>
  • <html lang="en">
  • <head>
  • <title>jQuery Set Value of Input Text Box</title>
  • <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  • <script>
  • $(document).ready(function(){
  •     $("#myInput").val("https://");
  • });
  • </script>
  • </head>
  • <body>
  •     <label>Enter Website URL:</label>
  •     <input type="text" id="myInput">
  • </body>
  • </html>

Related FAQ

Here are some more FAQ related to this topic:

Advertisements

Your Feedback:

We would love to hear from you, please drop us a line.