Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created October 13, 2025 19:12
Show Gist options
  • Select an option

  • Save rickalday/f549ee8ce8c4370f4a87c9768e746f3f to your computer and use it in GitHub Desktop.

Select an option

Save rickalday/f549ee8ce8c4370f4a87c9768e746f3f to your computer and use it in GitHub Desktop.
Make the first element of a GiveWP dropdown element non-selectable
<?php
add_action("givewp_donation_form_enqueue_scripts", function () {
?>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Run after a short delay to ensure UI is ready
setTimeout(() => {
//Assuming your select element has an name of 'favorite_color'
const selectElement = document.querySelector('select[name="favorite_color"]');
// Get the first option element
const firstOption = selectElement.options[0];
// Make the first option non-selectable
firstOption.disabled = true;
}, 100); // small delay to let GiveWP UI finish rendering
});
</script>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment