如何跳过一条线?

时间:2014-09-25 14:02:16

标签: javascript jquery

这是我的代码:

  <h3 class="ms-standardheader">
    <nobr>
       Reasons for proposals selected and not selected
    </nobr>
  </h3>
这是我的形象:
enter image description here

但我的文字太大了,我想插入<br>来跳过一条线,如下所示:
enter image description here

有可能吗?

2 个答案:

答案 0 :(得分:2)

单向:

$('nobr').html(function () {
    return $(this).html().replace('selected and', 'selected<br />and');
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<h3 class="ms-standardheader">
    <nobr>
       Reasons for proposals selected and not selected
    </nobr>
  </h3>

答案 1 :(得分:1)

试试这个剧本:

<script type="text/javascript">
  $(document).ready(function() {
    var e = "Reasons for proposals selected<br/> and not selected";
    $(".ms-standardheader nobr").html(e);
    });
  </script>