javascript - Using CoffeeScript to select default value for select box -
i'm trying set default value of select box. here current failed attempt.
$("#event_location_country").on "load", () -> $(this).val("us")
html
<%= f.select :location_country, countries, {}, class: "form-control", required: true %> <%= f.label :location_country, class: "form-note" %>
here html console:
<option value="us">united states</option>
obviously other countries of world want default on page load. also. there in easier way html?
have tried this?
<option value="us" selected>united states</option>
Comments
Post a Comment