Script to remove input fields
This commit is contained in:
@ -1,6 +1,19 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Remoev input field
|
||||
*
|
||||
* @param {event} the button click event
|
||||
*/
|
||||
function removeInput(event) {
|
||||
const trigger = event.currentTarget;
|
||||
const input_id = trigger.dataset.remove;
|
||||
const input = document.getElementById(input_id);
|
||||
|
||||
input.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Duplicate an input field
|
||||
*
|
||||
@ -29,4 +42,8 @@
|
||||
document
|
||||
.querySelectorAll("[data-duplicate]")
|
||||
.forEach((node) => node.addEventListener("click", duplicateInput));
|
||||
|
||||
document
|
||||
.querySelectorAll("[data-remove]")
|
||||
.forEach((node) => node.addEventListener("click", removeInput));
|
||||
})();
|
||||
|
Reference in New Issue
Block a user