简体   繁体   English

标题属性中的换行符在工具提示中不起作用

[英]New Line character in title attribute does not work in tooltip

I have an html form where I need to add new line character in to the title attribute of the anchor tag. 我有一个html表单,需要在其中将新行字符添加到锚标记的title属性中。 I found a few solutions online but none of them work in my code. 我在网上找到了一些解决方案,但是没有一个在我的代码中起作用。

I tried adding 我尝试添加
\\n





<br>



not sure what is missing. 不知道丢失了什么。 Is it because of data-toggle that is blocking from breaking the title attribute? 是由于数据切换阻止了破坏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 -&#013; You can provide further information here to for your&#013; application to issue a new card.&#013; Ensure a maximum of 200 characters&#013; is entered – including spaces."></a>

A popover would be a better solution, but it is possible to achieve this functionality in browser: 弹出窗口是一个更好的解决方案,但是可以在浏览器中实现此功能:

 $(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 -&#013; You can provide further information here to for your&#013; application to issue a new card.&#013; Ensure a maximum of 200 characters&#013; is entered – including spaces.">test</a> 

使用JavaScript设置标题对我来说很有效。

document.getElementById('asdf').title = 'line1\nline2';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM