我正在尝试在邮件客户端中的服务后添加换行符,但找不到有效的东西
我尝试了很多事情,例如<br />
,$#010;
,\n
,\n\r
我在代码中使用双引号
$(document).ready(function() {
//Save references to elements. Don't do DOM walks in event handlers when not needed.
var $sendEmailEl = $('#send-email');
var $subjectEl = $('#subject');
var $bodyEl = $('#body');
function getSelectedServices(){
var services = "";
$('input[type="checkbox"]').each(function(i,cb){
if($(this).is(":checked")){
services += $(this).val() + " | ";
}
});
return services;
}
function updateEmailLink() {
console.log(getSelectedServices());
$sendEmailEl.attr("href", "mailto:haghigsa@sheridancollege.ca?" +
"subject=" + "Makeup Inquiry" +
"&body=" +"Selected Services: "+ getSelectedServices()+"\r\n "+ encodeURIComponent($bodyEl.val()));
//console.log($sendEmailEl.attr('href'));
}
$('#subject,#body').on('input', updateEmailLink);
updateEmailLink();
});
没有错误,有时在客户端打开后,它会将我键入的内容添加到电子邮件中(例如
将仅包含在文本中),大多数情况下它会被忽略甚至不显示在邮件客户端中