It's such an unnecessary detour to always style reset an input element when you only want the event functionality.
Is there any HTML element that offers events and as well allows me to styling-wise "start from scratch"?
It's such an unnecessary detour to always style reset an input element when you only want the event functionality.
Is there any HTML element that offers events and as well allows me to styling-wise "start from scratch"?
DIV elements are not form elements.
There is no value
or name
attribute or property on a DIV element.
The easiest solution is to use an input element and remove all the default styling with CSS:
console.log(document.getElementById('div1').name); // undefined
console.log(document.getElementById('div1').value); // undefined
input {
border: none;
padding: none;
background-color: transparent;
outline: none;
}
<input type="text" value="Some text">
<div id="div1" name="name1" value="value1"> div content</div>