Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Answers
how to remove item using splice
ahmed salah
8y
245
1
Reply
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) {
// Not exist. Add new
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>
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
GridView in jquery
How to find gridview id and bind the data in another partial