-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
executable file
·73 lines (72 loc) · 2.67 KB
/
index.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Add And Remove Element JQuery</title>
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
</head>
<body>
<div class="container">
<div class="span12 ">
<div class="row">
<h3>Clone and Remove Inputs With JQuery</h3>
<form action="" method="post" accept-charset="utf-8">
<div id="divInputElement">
<p>
<label for="inputElement">Text: </label>
<input name="data[Customer][email][]" type="text" id="inputElement" required="required"/>
</p>
</div>
<div class="add">
<img src="img/plus.png" style="cursor: pointer;" title="Add" alt="" />
</div>
<div class="remove">
<img src="img/minus.png" style="cursor: pointer;" title="Remove" alt="" />
</div>
<div class="submit">
<p><input type="submit" value="Send"/></p>
</div>
<br/>
</form>
</div>
</div>
</div>
<style>
.add{
position: relative;
top: -44px;
left: 210px;
width: 33px;
display: inline-block;
}
.remove{
position: relative;
top: -44px;
left: 220px;
width: 33px;
display: inline-block;
}
</style>
<script>
jQuery(function() {
var i = 0;
jQuery('.remove').hide();
conteudo = jQuery("#divInputElement").html();
jQuery(".add").click(function() {
jQuery("#divInputElement").append(conteudo);
i++;
jQuery('.remove').show();
return false;
});
jQuery('.remove').click(function() {
jQuery('#inputElement:last').prev().remove();
jQuery('#inputElement:last').remove();
--i;
if (i == 0) {
jQuery('.remove').hide();
}
});
});
</script>
</body>
</html>