In meiner MVC Ansicht habe ich eine Länderliste, die mit allen Ländern bevölkert ist. Dies funktioniert in Ordnung und der Benutzer wählt verschiedene Länder aus. & Sie werden in Ordnung angezeigt. Ich möchte die Fähigkeit in Javascript, dieses Feld zurück zu "Select Country" zu ändern, wie mache ich das?mvc razor dropdownlistfor display standard von javascript
Dies ist meiner Ansicht nach
<div class="form-group">
@Html.DropDownListFor(model => model.country, ViewBag.countrylist as SelectList, "Select Country", htmlAttributes: new { @id = "ddlcountry" })
</div>
Dies ist mein Javascript
$("#ddlcountry").val(44); //this works to set the country code to 44
$("#ddlcountry").val("Select Country"); //this does not work to display "Select Country" like the default when you first load the page
Wie kann ich die Standardeinstellung "Land auswählen" Show haben wieder?
perfekt gearbeitet - danke! – e2fx