My code
<!DOCTYPE html>
<html>
<body>
<input type="text" id="text" value=""><br>
<button onclick="myFunction()">Submit</button>
<script>
function myFunction() {
var str = document.getElementById("text");
var res = str.replace("1", "2");
document.getElementById("text") = res;
}
</script>
in input field i am taking some input from user on (click) submit i want to replace all 1 with 2 and i want to display result in same field but its not working..