Javacript + html.
I have created an input of type "email" inside a form and a button. The user insert his mail to the input box, click the button and the input information will be saved to a cookie.
I have found that if the id name and onclick name on the button are similar it wouldn't work, I would like to understand why is that?
html:
<head>
<title>Document</title>
<link rel="stylesheet" href="main.css">
<script src="main.js"></script>
</head>
<body>
<form>
<input id="input" type="email">
<button id="saveMe" onclick="saveMe()">Save</button>
</form>
</body>
</html>
JS:
function saveMe() {
const input = document.getElementById("input")
document.cookie = "Email=" + input.value
}