Saturday, 7 May 2016

MVC - jQuery - Add new item to dropdownlist (select list)




Watch this example on youtube


<h2>AddItemsToDDL</h2>
<select id="Select1">
    <option value="1">Blue</option>
    <option value="2">Yellow</option>

</select>

<script type="text/javascript">
    $(document).ready(function () {
        var NewOption = "<option value='" + "3" + "'>Gold</option>";
        $("#Select1").append(NewOption);
    });
</script>

No comments:

Post a Comment