[英]javascript/jQuery: Adding linebreak in title — works in IE9, but not in IE8
I'm trying the following to add a linebreak in the title
attribute. 我正在尝试以下在
title
属性中添加换行符。
<p id="test" title="1|2">test</p>
var lineBreak = $("<div>
</div>").html();
$("#test").attr("title", $("#test").attr("title").replace("|", lineBreak));
The tooltip result in IE9 is IE9中的工具提示结果是
1
2
in IE8 the result is 在IE8中 ,结果是
12
Is there a chance to fix this for IE8? 有机会为IE8修复此问题吗? I really need this way and no custom tooltip etc.
我真的需要这种方式,没有自定义工具提示等。
Try it @ jsfiddle: http://jsfiddle.net/8ZCdb/ 尝试@ jsfiddle: http : //jsfiddle.net/8ZCdb/
Try this: 尝试这个:
$("#test").attr("title", $("#test").attr("title").replace("|", "\n"));
\\n
is a new line operator in plain text. \\n
是纯文本格式的换行符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.