You do not need "setInterval" for this action
When the button element is in form element, it defaults to the send function, which in this case refreshes the page. Thus, the contents of the field are cleaned as soon as it has been filled.
I removed the form element. Now, when a button is clicked, the contents of the input element are taken and displayed in the p element
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input id="mail" type="text" name="email" value="[email protected]">
<button id="btn" onclick="abc()">click On me</button>
<p id='text'></p>
<script>
function abc() {
var mail = document.getElementById('mail');
var text = document.getElementById('text');
text.innerText = mail.value;
}
</script>
</body>
</html>
Version with setInterval
After pressing the button "setInterval" will be activated. Every 100ms it will takes all the information from the input element and will fill it in the P element. You can write in the field and the text will immediately appear in the other element. In order not to accumulate spaces after pressing the button, I have set a line in the code that deactivates the button
function abc() {
document.getElementById('btn').setAttribute("disabled", true);
setInterval(() => {
var mail = document.getElementById('mail');
var text = document.getElementById('text');
text.innerText = mail.value;
}, 100);
}
<input id="mail" type="text" name="email" value="[email protected]">
<button id="btn" onclick="abc()">click On me</button>
<p id='text'></p>