How to Change the Value of an Input in jQuery
In this tutorial, we are going to see how to change the value of an input in jquery. You can simply use jQuery’s val() method to set the value of an input.
Try the following example to see how it actually works:
How to Change the Value of an Input in jQuery
<!DOCTYPE html> <html> <head> <title>Change the Value of an Input in jQuery</title> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <script> $(document).ready(function(){ $("#email").val("[email protected]"); }); </script> </head> <body> <label>Please enter your e-mail address:</label> <input type="text" id="email"> </body> </html>
Result |
---|