使用 jQuery 将文本换行在 <nobr> 标记内
wrap text inside <nobr> tag using jquery
我有<nobr>
标签中的共享点 gererate 标签。但是在页面上它太长了,我需要使用 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>
标签。
尝试这样做:
$('.ms-formlabel nobr').css('white-space', 'normal');
<nobr>
标签通常具有 CSS white-space
nowrap
。
如果您需要删除 nobr 标签并保留文本,您应该
var text = $(".ms-formlabel nobr").html()
$(".ms-formlabel h3").html(text);
如果您只想删除 nobr 标签并删除文本,只需:
$(".ms-formlabel nobr").remove();
好的,所以听起来你被迫接收<nobr>
标签。 如果我是你,我会将它们转换为<p>
标签。
$('nobr').each(function() {
$(this).after('<p>' + $(this).html() + '</p>');
$(this).remove();
});
如果您只想将文本保留在其中,请使用 .text()
而不是 .html()
. 您也可以使用 <div />
而不是 <p />
标记。
相关文章:
- 无法从 jQuery RSS Feed 中的 localStorage 动态替换类
- 如何使用jQuery自动打开页面上的所有链接
- 如何使用jquery在填充自动完成的值后使文本框只读
- jQuery:循环一个具有不同超时值的循环
- 用程序搜索JQuery数据表中的文本
- 使用 jQuery 的 .on 函数如何获取事件的原始元素
- jQuery匹配JSON对象的部分文本
- Jquery POST未填充数组
- JQuery使计数器每次更改时都会增加
- 如何在Angular2中使用jQuery插件
- 提高JQuery的性能
- 无法在通过jQuery的ajax加载的页面中执行javascript
- JQuery合并了keyup和focusout两个函数
- 如何使用jQuery选择下拉列表的值
- 将PHP变量传递给jQuery时遇到问题
- jQuery UI自动完成突然停止工作
- 剑道网格jQuery动画()问题
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- jquery点击函数select&取消选择
- jquery试图按名称获取按钮位置