Reputation: 1
I want to pre-select a certain option in a dropdown list and want to use the "selected" parameter in HTML to select it. Is this possible?
<option value="@cat.ID"
@if(cat.ID == 2){
@: selected );
}
>@cat.Category</option>
Upvotes: 0
Views: 233
Reputation: 10141
To select a default option, you can do this:
var elm = new Dropkick("#select");
// Select by index
elm.select(4); //selects & returns 5th item in the list
// Select by value
elm.select("AL"); // selects & returns option with the value "AL"
Reference documentation: http://dropkickjs.com/api.html#method-select
Upvotes: 0