简体   繁体   中英

wrap text inside <nobr> tag using jquery

I have sharepoint gererate lable which is in <nobr> tag. But on the page it is so long I need to wrap this using 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>

Better option is remove <nobr> tag. Is it possible to remove based on text? because there are other so many other <nobr> tags on the page.

Try doing this:

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

The <nobr> tag usually has a CSS white-space of nowrap .

If you need to remove nobr tag and keep the text you should

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

If you just want to remove the nobr tag and remove the text just:

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

Okay, so it sounds like you are forced into receiving <nobr> tags. If I were you, I'd just convert them to <p> tags then.

$('nobr').each(function() {
    $(this).after('<p>' + $(this).html() + '</p>');
    $(this).remove();
});

If you only want to keep the text inside of them, then use .text() instead of .html() . You could alternatively use <div /> instead of the <p /> tags.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM