Monday, 16 October 2017

MVC - jQuery - Trick to quickly lear select element (drop down list)


Watch on YouTube

<div>
    <select id="Products">
        <option>Product 1</option>
        <option>Product 2</option>
        <option>Product 3</option>
        <option>Product 4</option>
        <option>Product 5</option>
    </select>
</div>
<input type="submit" value="clear drop down list" id="btnClear" />

and scripts

@section Scripts{
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnClear").click(function (e) {
                $("#Products").empty();
            });
        });
    </script>
}

No comments:

Post a Comment