Search

How to Set the Value of Input Text Box using jQuery

post-title

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>