im trying to do submit with enter in the form tag, but its not working
here is my code
document.querySelector('#button').addEventListener('submit',(e)=>{
e.preventDefault()
console.log('it works')
})
<ul>
<li>
<div>
<form>
<input></input>
<button type="submit" id='button'></button>
</form>
</div>
</li>
</ul>
Submit events fire on form elements, not button elements.
You're listening for the event in the wrong place.