jQuery dynamisch Eingabefelder funktioniert nicht
Ich habe hier ein Tutorial verfolgt (das ich ein wenig modifiziert habe):Code
In JSFiddle funktioniert der Code einwandfrei. Auf der eigentlichen Seite, deren Code unten angegeben ist, funktioniert er jedoch nicht. Ich habe Probleme, aber ich kann keine Antwort finden :-(, daher ist jede Hilfe willkommen.
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="javascript/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$('.multi-field-wrapper').each(function() {
var $wrapper = $('.multi-fields', this);
$(".add-field", $(this)).click(function(e) {
$('.multi-field:first-child', $wrapper).clone(true).appendTo($wrapper).find('input').val('').focus();
});
$('.multi-field .remove-field', $wrapper).click(function() {
if ($('.multi-field', $wrapper).length > 1)
$(this).parent('.multi-field').remove();
});
});
</script>
<title>AQUATAP - Gestor de Información - Añadir Pedido</title>
</head>
<body>
<form role="form" action="add_order.php" method="POST">
Cliente:
<input type="text" name="cliente" id="buscar">
<br>
<hr />
Fecha de salida:
<br>
<input type="radio" name="salida_pronosticada" value="male">
En el día
<br>
<input type="radio" name="salida_pronosticada" value="male">
2 días
<br>
<input type="radio" name="salida_pronosticada" value="female">
3 días
<br>
<input type="radio" name="salida_pronosticada" value="female">
5 días
<br>
<input type="radio" name="salida_pronosticada" value="female">
1 semana
<br>
<input type="radio" name="salida_pronosticada" value="female">
Otro
<input type="text" name="salida_pronosticada_otro">
días
<br>
<hr />
<label>Stuff y cantidad</label>
<div class="multi-field-wrapper">
<div class="multi-fields">
<div class="multi-field">
<input type="text" class="buscar_prod" name="input_referencia[]">
<input type="text" name="input_cantidad[]">
<button type="button" class="remove-field">
X
</button>
</div>
</div>
<button type="button" class="add-field">
Add field
</button>
<input type="submit" name="guardar" value="Guardar" />
</div>
</form>
</body>
Also gut ... jede Hilfe wird geschätzt. Ich habe herumgespielt und denke, dass mir etwas fehlen könnte ... als ob das Drehbuch nicht gestartet worden wäre.