[英]\n as well as <br> for new line in JavaScript alert not working
您只需添加CSS
white-space: pre-line;
用於彈出內容。
這是工作示例。
jQuery(document).ready(function($) { $('button').click(function(e){ e.preventDefault(); var v_date = '04/11/2019'; var school_name = 'School Name'; var school_city = 'School City'; new Attention.Alert({ title: 'This is a Title', content: 'Date - '+v_date+'\n School Name - '+school_name+'\n School City - '+school_city }); }); });
*, *:after, *:before{ box-sizing: border-box; } body { font-family: 'Open Sans', serif; background-color: #d1d8de; padding: 20px; }.attention-component.inner-container p{ white-space: pre-line; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://janmarkuslanger.github.io/attention.js/dist/attention.js"></script> <link href="https://janmarkuslanger.github.io/attention.js/dist/attention.css" rel="stylesheet"> <button>Click</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.