-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery_append_input.html
More file actions
36 lines (36 loc) · 963 Bytes
/
jquery_append_input.html
File metadata and controls
36 lines (36 loc) · 963 Bytes
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
<html>
<head>
<title>jQuery - Append Input</title>
<style>
form {
font-size: 12px;
font-family: Verdana, Arial, Sans-Serif;
display: inline-block;
}
#messages {
font-size: 14px;
font-family: Garamond, Times, Serif;
}
</style>
<script src="js/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('button').click(function() {
var toAdd = $('input[name=message]').val();
$('#messages').append('<div class="item">' + toAdd + '</div>');
});
$('input').focus(function() {
$(this).css('outline-color', '#0000FF');
});
$(document).on('click', '.item', function() {
$(this).remove();
});
});
</script>
</head>
<body>
<form>Input: <input type="text" name="message" value=""></form>
<button>Add</button><br>
<div id="messages"></div>
</body>
</html>