Last active
April 22, 2024 14:18
-
-
Save fgbarrios/deb2014a5177c939bdacc887901b7bc8 to your computer and use it in GitHub Desktop.
Select Form Field - Placeholder Option (for Elementor)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Follow up for this thread: https://wordpress.org/support/topic/select-form-field-placeholder-option/ | |
- The first option of your select form must be the placeholder. | |
- Then, in your JQuery file, copy the code and replace "theName" and "theValue" with the data of your select. | |
Example: | |
---- On a HTML page ----- | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-latest.min.js"></script> | |
<script src="/yourJSfile.js"></script> | |
</head> | |
<body> | |
<select name="form_fields[selectorActividad]" id="form-field-selectorActividad" class="elementor-field-textual elementor-size-sm"> | |
<option value="Seleccione su actividad…">Seleccione su actividad…</option> | |
<option value="Acopiador">Acopiador</option> | |
<option value="Productor">Productor</option> | |
<option value="Canjeador">Canjeador</option> | |
<option value="Exportador">Exportador</option> | |
<option value="Corredor">Corredor</option> | |
<option value="Distribuidor">Distribuidor</option> | |
</select> | |
</body> | |
</html> | |
---- Your 'yourJSfile.js' ----- | |
jQuery(document).ready(function( $ ){ | |
document.querySelector('select[name="form_fields[selectorActividad]"] option[value="Seleccione su actividad…"]').disabled = true; | |
document.querySelector('select[name="form_fields[selectorActividad]"] option[value="Seleccione su actividad…"]').hidden = true; | |
}); | |
*/ | |
jQuery(document).ready(function( $ ){ | |
document.querySelector('select[name="theName"] option[value="theValue"]').disabled = true; | |
document.querySelector('select[name="theName"] option[value="theValue"]').hidden = true; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment