UNPKG

@finsweet/ts-utils

Version:

Typescript utils for custom Webflow projects.

14 lines (13 loc) 430 B
/** * Removes all the options from an HTMLSelectElement. * @param selectElement * @param preserveEmpty If set to true, any option without a value (like a placeholder option) will be preserved. */ export const removeSelectOptions = ({ options }, preserveEmpty = false) => { for (const option of [...options]) { if (preserveEmpty && !option.value) { continue; } option.remove(); } };