Change value of selectbox in Zurb Foundation via JavaScript
Change value of selectbox in Zurb Foundation via JavaScript
Some of us tried to change or will have to change via javascript a select-box that is generated from the custom forms of Zurb Foundation framework. You noticed or you will notice that it is not as simple as changing a default html select-box. Why ? Because if you inspect the elements of that select-box, you will see that it is actually a rendered list to obtain the desired layout and style that they are offering.
First method
1 2 3 4 5 |
// Change selected option $('#element').val('1'); // Fire change event $('#element').trigger('change'); |
Second method
1 2 3 4 |
<script type="text/javascript"> $("#selectCategoryForQ").val(0); Foundation.libs.forms.refresh_custom_select($("#selectCategoryForQ"), true); </script> |
For those who still don’t know what I am talking about, this is a tutorial that I wrote in the past about using this responsive frontend framework.