我正在尝试使用jQuery将html文档中的介绍/帮助文本包装起来。它不在任何标签内,而是在两个闭合的html标签之间。请参见附加的代码片段作为示例。第二个结束标记也可以是除
& lt; p & gt;之外的其他内容。
var txtHelp = jQuery('b.page-title').nextUntil('p').text();
console.log(txtHelp);
//jQuery('b.page-title').nextUntil('p').text().wrap("<p />");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<b class="page-title"><h4>System Log</h4><hr class="text-primary"></b>
How to select this text and wrap it in new P-Tag
<p align="center">This can by any html tag</p>
$('b.page-title')[0].nextSibling.textContent
- haim770