-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilista.html
47 lines (41 loc) · 1.04 KB
/
milista.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html>
<head>
<title>Mi lista </title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
<style>
h1 {
color: #1abc9c;
}
.rem {
margin-left: 5px;
background-color: white;
color: red;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Mi lista </h1>
<input type="text" placeholder="Nuevo" />
<button id="add">Agregar </button>
<ol id="mylist"></ol>
<script>
$(function() {
$("#add").on("click", function() {
var val = $("input").val();
if(val !== '') {
var elem = $("<li></li>").text(val);
$(elem).append("<button class='rem'>X</button>");
$("#mylist").append(elem);
$("input").val("");
$(".rem").on("click", function() {
$(this).parent().remove();
});
}
});
});
</script>
</body>
</html>