嗨我正在使用下面的代码来构建一个字符串并复制它,但在输出时,当我粘贴它时,换行符不适用
@H_502_8@解决方法
function copyToClipboardShipto() { var $temp = $("<input>"); $("body").append($temp); var str1 = "@(Model.firstName)"; var str2 = " "; var str3 = "@(Model.lastName)"; var str4 = "\n"; var str5 = "@(Model.shiptoes[0].address.address1)"; var str6 = ","; var str7 = "@(Model.shiptoes[0].address.address2)"; var str8 = "\n"; var str9 = "@(Model.shiptoes[0].address.city)"; var str10 = ","; var str11 = "@(Model.shiptoes[0].address.state)"; var str12 = "\n"; var str13 = "@(Model.shiptoes[0].address.zip)"; var str = str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + str9 + str10 + str11 + str12 + str13; $temp.val(str).select(); document.execCommand("copy"); $temp.remove(); } }
名字lastname223 E JACKSON AVE,city,statezip
有任何帮助
使用< textarea>而不是< input>,因为INPUT不支持多行字符串.
var $temp = $("<textarea>");