14

我想了解如何在标题属性中添加中断,我想在标题属性中添加中断以区分名称。如何在标题属性中添加中断?

我有这样的东西

<p title="this is a description of the some text <br> and further description">Some Text</p>

结果是:图像显示 <br> 而不是制动。

4

2 回答 2

10

如果您在需要换行符的位置添加新行,它适用于某些浏览器,但不是全部。

例子:

div { background-color: #c3c3c3; display: block; width: 100px; height: 100px; }
<div title="This is a text
    Second line
    Third line!">Contents</div>

JSFiddle:http:
//jsfiddle.net/g5CGh/

于 2013-11-14T15:45:22.580 回答
6

在标题文本中替换<br>&lt;br /&gt;

<p title="this is a description of the some text &lt;br /&gt; and further description">Some Text</p>

现在<br />用换行符\n(jquery)替换:

<script>
    $(document).ready(function(){
    $('p').each(function(){
        var a = $(this).attr('title');
        var b = a.replace('<br />','\n');
        $(this).attr('title', b);
    });
    });
</script>

希望我对你有所帮助

于 2013-11-14T16:12:48.350 回答