在textarea文本编辑时不追加附加函数。我试着拉出当前的值,追加,然后放回去。但却无法工作。
function getSerial() {
var getValue = $(serial).val() + ",\n";
var showValue = "#showSerial";
$(showValue).append(getValue);
} 如果我使用val(),它将替换为前面提交的值。文本区域的值将添加逗号,如AL-2,Al-3,每一次提交.
发布于 2015-04-07 10:24:41
尝试使用val()而不是append():我已经创建了一个测试小提琴,这对您有用吗?
function getSerial (){
var showValue = $("#showSerial");
var getValue = $(serial).val()+ ",\n";
if(showValue.val()){
$(showValue).val(showValue.val() + getValue);
}else {
$(showValue).val(getValue);
}
}发布于 2015-04-07 10:20:35
使用.append()代替.val()
发布于 2015-04-07 10:19:38
使用.append()代替.val(),如图所示:-
function getSerial (){
var getValue = $(serial).val()+ ",\n"; //make sure serial variable is defined above this line
var showValue = "#showSerial";
$(showValue).val(getValue + $(showValue).text()); //instead of .append() use .val()
}https://stackoverflow.com/questions/29489189
复制相似问题