使用jquery在<nobr>标记内包装文本

时间:2016-02-18 16:42:47

标签: javascript jquery html

我有<nobr>标签中的sharepoint gererate lable。但是在页面上我需要使用jquery来包装它。

<td nowrap="true" valign="top" width="113px" class="ms-formlabel"><h3 class="ms-standardheader">
    <nobr>On a scale of 1 to 10, with 1 being the lowest and 10 the highest, please rate your overall satisfaction with the management and implementation of this project?  Rating:</nobr>
</h3></td>

更好的选择是删除<nobr>标记。是否可以根据文本删除?因为页面上还有其他许多其他<nobr>标签。

3 个答案:

答案 0 :(得分:0)

尝试这样做:

$('.ms-formlabel nobr').css('white-space', 'normal');

<nobr>代码的white-space通常为nowrap

答案 1 :(得分:0)

如果您需要删除 nobr 标记并保留文字,则

var text = $(".ms-formlabel nobr").html()
$(".ms-formlabel h3").html(text);

如果您只想删除 nobr 标记并删除文字:

$(".ms-formlabel nobr").remove();

答案 2 :(得分:0)

好的,所以听起来你被迫接收SELECT WORKDAY_ADD('2016-02-18', -2)标签。如果我是你,我只需将它们转换为<nobr>标签。

<p>

如果您只想将文字保留在其中,请使用$('nobr').each(function() { $(this).after('<p>' + $(this).html() + '</p>'); $(this).remove(); }); 代替.text()。您也可以使用.html()代替<div />代码。

相关问题