无法换行

时间:2013-03-04 09:26:40

标签: c# javascript jquery asp.net html

我正在尝试使用多行文字创建动态工具提示,一切正常但下一行却没有。还有什么想法让我进行换行吗?

<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();

1 个答案:

答案 0 :(得分:0)

.text()将对HTML标记进行编码,并将其与文本一起显示。

尝试更换:

Tip.text(data[ToolTipID]);

使用:

Top.html(data[ToolTipID]);