Bonjour, Newbie JS, je galère avec ce script trouvé au hasard du web...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
<head><script src="contenu/js/jquery-3.4.1.min.js"></script></head>
 
<body>
<div class="card-body">
		<form name="" action="" method="POST">
			<table id="maTable">
			<tbody>
 
 
			<?php foreach ... : ?>
 
			<tr>
				<td class="col-sm-1">
					<input type="text" class="form-control" name="ordre[]" value="..." />
				</td>	
				<td class="col-sm-3">
					<input type="text"  class="form-control" name="titre[]" value="..." />
				</td>
				<td class="col-sm-7">			
					<textarea  rows="5" class="form-control"  name="article[]" >...</textarea>
				</td>
				<td class="col-sm-1">
					<input type="button" class="ibtnDel btn btn-md btn-danger "  value="-">
				</td>
			</tr>
			<?php endforeach ; ?>
			<tr>
				<td colspan="3">
				<input type="button" class="btn btn-lg btn-block " id="addrow" value="Ajouter" />
				</td>
			</tr>
			 </tbody>
			<tfoot>
			<tr>
				<td colspan="3">
					<button class="btn btn-lg btn-block btn-primary" type="submit" name="">Valider</button>
				</td>
			</tr>
			</tfoot>
			</table>
 
		</form>
		</div>
		<script>
		$(document).ready(function () {
		    var counter = 0;
 
		    $("#addrow").on("click", function () {
			var newRow = $("<tr>");
			var cols = "";
 
			cols += '<td class="col-sm-1"><input type="text" class="form-control" name="ordre[]"/></td>';  
			cols += '<td class="col-sm-3"><input type="text" class="form-control" name="titre[]"/></td>';  
			cols += '<td class="col-sm-7"><textarea  rows="5" class="form-control" name="article[]"></textarea></td>'; // ' + counter + '
			cols += '<td class="col-sm-1"><input type="button" class="ibtnDel btn btn-md btn-danger"  value="Effacer"></td>';
			newRow.append(cols);
			$("table.order-list").append(newRow);
			counter++;
		    });
 
		    $("table.order-list").on("click", ".ibtnDel", function (event) {
			$(this).closest("tr").remove();       
			counter -= 1
		    });
		});
		</script>
</body>
Ce script ne fonctionne pas (pourtant il fonctionne sur d'autres pages du site) Merci de votre aide