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

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -