in code below i need to using splice in place of remove function
how to do that please
- <script>
- $(function () {
- $(document).on("click", ".remove", function (e) {
- e.preventDefault();
- $(this).closest(".course-item").remove();
- });
- $('#AvailableCourses').change(function () {
- var val = $(this).val();
- var text = $("#AvailableCourses option:selected").text();
- var existingCourses = $("input[name='CourseIds']")
- .map(function () { return this.value; }).get();
-
- if (existingCourses.indexOf(val) === -1) {
-
- var newItem = $("<div/>").addClass("course-item")
- .append(text + ' <a href="#" class="remove" data-id="' + val + '">Remove </a>');
- newItem.append('<input type="text" name="CourseIds" value="' + val + '" />');
-
- $("#items").append(newItem);
- }
- });
- });
- </script>