1
下面是我的工作:3克隆与数学函数A/B = C的文本域。完美工作。设置输入值克隆
问题:我想设置A,B和C的“on keyup”上的文本字段值,以便实际读取输入到文本字段中的值。 (参见代码中的注释 “不对”)
$("#math-table input").live("keyup", function(){
var id = this.id.match(/\d+/);
$("#C"+id).val(Math.round (($("#A"+id).val()/$("#B"+id).val()) * 100) + "%" );
$('#A1'+id).attr('value', ($('#A1'+id).val())); // NOT RIGHT?
$('#B1'+id).attr('value', ($('#B1'+id).val())); // NOT RIGHT?
$('#C1'+id).attr('value', ($('#C1'+id).val())); // NOT RIGHT?
});
var uniqueIds = $("#math-table tr").length;
$("#math-table input[id^='B']").live("change", function(){
var $thisRow = $(this).closest("tr"),
$clone = $thisRow.clone(), // Clone row
$inputs = $clone.find("input").val("");// Reset values, return all inputs
uniqueIds++; //Increment ID
$inputs[0].id = "A" + uniqueIds;
$inputs[1].id = "B" + uniqueIds;
$inputs[2].id = "C" + uniqueIds;
$thisRow.after($clone);
});
A [jsFiddle](http://jsfiddle.net/)会有所帮助。 – sczizzo 2011-12-30 02:32:52
当然,谢谢! http://jsfiddle.net/CzZxf/ – user1040259 2011-12-30 02:47:37