How to Set the Value of Input Text Box using jQuery

1058 views 2 years ago jQuery

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>

Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]