#78 - Effacer les entrées sur le clic

Créez un bouton qui peut effacer les valeurs d'une ou plusieurs entrées.

Video Tutorial

Loom
tutorial.mov

Watch the video for step-by-step implementation instructions

The Code

17 lines
Paste this into Webflow
<!-- 💙 MEMBERSCRIPT #78 v0.1 💙 CLEAR INPUT VALUES ONCLICK -->
<script>
document.addEventListener('DOMContentLoaded', () => {
  const clearBtns = document.querySelectorAll('[ms-code-clear-value]');
  clearBtns.forEach(btn => {
    btn.addEventListener('click', () => {
      const fieldIds = btn.getAttribute('ms-code-clear-value').split(',');
      fieldIds.forEach(fieldId => {   
        const input = document.querySelector(`[data-ms-member="${fieldId}"]`);
        if (input) {
          input.value = '';
        }
      });
    });
  });
});
</script>

Data Attributes

1 attribute
Attribut
Value
Description
vrai
No description

How to use attributes

Add these data attributes to your HTML elements in Webflow. For example: <div data-attribute="value">

Script Info

Versionv0.1
PublishedNov 11, 2025
Last UpdatedNov 11, 2025

Need Help?

Join our Slack community for support, questions, and script requests.

Join Slack Community
Back to All Scripts

Related Scripts

More scripts in UX