How to clear textbox in Javascript?
clear textbox js
function name()
{
document.getElementById('elementid').value = "";
}
how to clear textbox in javascript
jQuery("#searchField").focus( function()
{
$(this).val("");
} );
Example 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
input{
color:gray;
}
</style>
</head>
<body>
<input type="text" value="Enter value" onfocus="vanish()" id="input">
<script>
function vanish(){
input = document.getElementById("input");
if(input.value=="Enter value"){
input.value = '';
}
}
</script>
</body>
</html>
Output

Once you click the textbox, the Enter Value will be cleared automatically.
