tag to set the dropdown's value and dispatch a 'change' event on page load.
To set a default option for a select dropdown in Webflow e-commerce using basic JavaScript, you can inject a small script to select the desired option on page load.
variant-select
, size-dropdown
, etc.).</body>
tag if using Page Settings.Example basic script:
<script> document.addEventListener("DOMContentLoaded", function () { const dropdown = document.querySelector('.your-class-name'); if (dropdown) { dropdown.value = "YourOptionValue"; // Trigger change event if needed dropdown.dispatchEvent(new Event('change')); } });</script>
.your-class-name
with the actual class you assigned to the <select>
element."YourOptionValue"
with the value
of the <option>
you want to select by default. This must match exactly.dropdown.dispatchEvent(new Event('change'))
to simulate a user interaction so Webflow’s bindings (e.g., e-commerce variant switching) are properly triggered.To set a default option for a select dropdown in Webflow e-commerce, use JavaScript targeting the dropdown's class and set its .value
. Be sure to trigger a change
event so Webflow recognizes the default selection properly.