Capturing button click in JavaScript
-
Great plugin – thanks for making it!
I’m trying to incorporate repeatable fields into a custom quote form. I have set up a document.addEventListener that looks at the class name to determine when to update the calculations with no problem. My problem is when the user clicks the wpcf7-field-group-remove button I can’t figure out how to grab that event. I useddocument.addEventListener( ‘change’, function (event) {
if (event.target.classList.contains(‘wpcf7-field-group-remove’)) {
console.log(‘remove happened’);
calculate(form, discount);
}
});
Any pointers on how to do this in JavaScript (not jQuery)?
It looks like from the plugin code
$( ‘body’ ).on( ‘click’, ‘.wpcf7-field-group-add, .wpcf7-field-group-remove’, function() {});
would work, but all the rest of my code is vanilla JS.
Thanks!
- The topic ‘Capturing button click in JavaScript’ is closed to new replies.