0

我正在尝试使用多行文本创建一个动态工具提示,一切正常,但下一行却不行。我还有什么想法可以换行吗?

<script type="text/javascript">
var data = {
    name: "enter your name",
    family: "enter your family",
    testfamily: "enter your family",
  //HERE IS WHERE I AM TRYING TO PERFORM LINE BREAK, BUT I FAILED
    uc1_txtname: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <br>\n\r<br\>\t <\br> aaaaaaa',
    uc2_txtname: "enter your name for Control 2 (User Control2)",
    family1: "THis is button  tooltips"
}

function ShowTooltip() {
    var Tip = $("<div class='dinamictip'></div>");
    $("input").hover(function () {
        Tip.text('');
        var ToolTipID = $(this).attr('id');
        var offset = $(this).offset();
        var height = $(this).height() + 10;

        Tip.text(data[ToolTipID]);

        Tip.css('display', 'inline')
          .css('position', 'absolute')
          .css('background', 'lightyellow')
          .css('border', '1px solid #cccccc')
          .css('color', '#6c6c6c')
          .css('left', offset.left)
          .css('top', offset.top - height)
          .css('border-radius','15px')



        Tip.appendTo('body');
    },

            function () {
                Tip.remove();
            });
}


ShowTooltip();

4

1 回答 1

0

.text()将对 HTML 标记进行编码并在文本旁边显示它们。

尝试更换:

Tip.text(data[ToolTipID]);

和:

Top.html(data[ToolTipID]);
于 2013-03-04T09:59:31.340 回答