我有一个html表单,我需要在锚标记的title属性中添加换行符。我在网上找到了一些解决方案,但它们都没有在我的代码中运行。
我尝试添加
\n





<br>


不确定缺少什么。是因为数据切换阻止了打破title属性?
$(document).ready(function () {
$('form').attr('novalidate', true);
$('[data-toggle="tooltip"]').tooltip();
<a class="helptext fa fa-question-circle" data-toggle="tooltip" title="Additional information -
 You can provide further information here to for your
 application to issue a new card.
 Ensure a maximum of 200 characters
 is entered – including spaces."></a>
答案 0 :(得分:1)
popover是一个更好的解决方案,但可以在浏览器中实现此功能:
$(document).ready(function () {
$('form').attr('novalidate', true);
//$('[data-toggle="tooltip"]').tooltip();
$('.helptext')[0].title = "I like\nlines"
// you can also use $('.helptext').attr("title",decodeURI("I like%0A to%0Ause%0Alines"))
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="helptext fa fa-question-circle" data-toggle="tooltip" href="#" title="Additional information -
 You can provide further information here to for your
 application to issue a new card.
 Ensure a maximum of 200 characters
 is entered – including spaces.">test</a>
答案 1 :(得分:1)
使用JavaScript设置标题对我有用。
document.getElementById('asdf').title = 'line1\nline2';