我有例如3個字段則該用戶可以輸入一個數A,B,C如何處理與jquery具有陣列
所以C區域將檢查在C區域輸入的號碼是<一個和新字段>灣
在表單中我有一個按鈕,用於創建另一行 另一個a,b,c;所以我不知道如何控制像以前一樣操作...
$(".c").change(function() {
if ($('.c').val() > $('.a').val() || $('.c').val() < $('.b').val()) {
$('.c').css("backgroundColor", "#ff0000");
} else {
$('.c').css("backgroundColor", "#00FF00");
}
});
$('.add').click(function() {
var tr = '<tr>' + '<td>Cota1</td>' +
'<td><input type="text" name="tol_cota1[]" class="form-control a"></td>' +
'<td><input type="text" name="tolb_cota1[]" class="form-control b"></td>' +
'<td><input type="text" name="medido_cota1[]" class="form-control c"></td>' +
'<td><input type="button" class="btn btn-danger remove" value="Remove Line"></td>' + '</tr>';
$('.details').append(tr);
});
// delete row
$('.details').delegate('.remove', 'click', function() {
var con = confirm("Are you sure you want to remove the line?");
if (con) {
$(this).parent().parent().remove();
}
});
'.delegate'被'.on' jQuery的1.7(幾年前)取代,並在3.0過時。您不應該將它用於新代碼。 http://api.jquery.com/Delegate/ – ADyson