JavaScript
Deactivate submit buttons (jQuery vs. Web API)

by Benny Neugebauer

const selector = '#form button[type=submit]';
const element = $(selector);
element.on('click', event => event.preventDefault());

const selector = '#form button[type=submit]';
const element = document.querySelector(selector);
element.addEventListener('click', event => event.preventDefault());

Instead of using the deprecated event.preventDefault() function, just return false. It does exactly the same thing.

Foxatron

Oh, forgot to say, you could shorten the blue side with element.onclick instead of addEventListener

Foxatron

Sign in to comment!