Skip to content

Commit f63d033

Browse files
removing the parent element
Signed-off-by: Arnav Gupta <arnav@codingblocks.com>
1 parent 7de3e29 commit f63d033

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

dom-manipulation/todo-jquery/script.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
$('#addtask').click(function() {
33
$('#tasklist').append(
44

5-
$('<li>').text($('#newtask').val())
5+
$('<li>')
6+
.append(
7+
$('<button>')
8+
.text('❌')
9+
.click(function (ev) {
10+
// ev -> the event
11+
// ev.target -> the element on which click happened
12+
// parent() -> the li element
13+
$(ev.target).parent().remove()
14+
})
15+
)
16+
.append($('<span>').text($('#newtask').val()))
617
)
18+
19+
$('#newtask').val('')
20+
721
})

0 commit comments

Comments
 (0)