由於某些原因,\ n在javascript中不適用於我。有無論如何解決它或使用HTML?在我的情況下,我認爲使用<br>
將無法在我的href中工作。你有什麼建議。 n不能在JavaScript中工作
Working JSFiddle here。
HTML:
<a id = 'emailoff' href = "" target = "_blank">
<div id= "btn1">
<h2 id = "enter">Send Email</h2>
</div>
</a>
的Javascript:
$('#btn1').click(function() {
$("#emailoff").attr("href", "mailto:" +
"?subject=Your ThinOptics glasses" +
"&body=To get your new ThinOptics glasses simply click this link and pick the case and color you like best. You'll get free shipping on your order. \n"+
" WWw.Thinoptics.Com/[email protected] \n" +
"\n Enjoy")
});
'\ n'確實可以在JavaScript中工作。但你的問題是,HREF得到多線,你正確的想要逃避新線,所以郵件客戶端得到'\ N',可以把它當作'\ n':TLDR:使用'\\ n',但支持可以因客戶而異。 – andlrc
這可能會回答你的問題http://stackoverflow.com/questions/1155678/javascript-string-newline-character –
@NULL「\\ n」似乎沒有工作......你的意思是替換「\ n 「與」\\ n「? –