Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 需要<;br/>;继续阅读前标记→;在每个<;p>;标记我让文本继续阅读的位置→;_Jquery - Fatal编程技术网

Jquery 需要<;br/>;继续阅读前标记→;在每个<;p>;标记我让文本继续阅读的位置→;

Jquery 需要<;br/>;继续阅读前标记→;在每个<;p>;标记我让文本继续阅读的位置→;,jquery,Jquery,现在我的输出是这样的 <p>text text text Continue reading →</p> <p>text1 tex1t text1 Continue reading →</p> <p>text2 text2 text2 Continue reading →</p> <p>text text text <br/> Continue reading →</p>

现在我的输出是这样的

 <p>text text text  Continue reading →</p>
  <p>text1 tex1t text1  Continue reading →</p>
  <p>text2 text2 text2  Continue reading →</p>
 <p>text text text <br/> Continue reading →</p>
  <p>text1 tex1t text1 <br/>  Continue reading →</p>
  <p>text2 text2 text2 <br/> Continue reading →</p>
文本继续阅读→

text1 tex1t text1继续阅读→

text2text2text2继续阅读→

但我需要像那样

 <p>text text text  Continue reading →</p>
  <p>text1 tex1t text1  Continue reading →</p>
  <p>text2 text2 text2  Continue reading →</p>
 <p>text text text <br/> Continue reading →</p>
  <p>text1 tex1t text1 <br/>  Continue reading →</p>
  <p>text2 text2 text2 <br/> Continue reading →</p>
文本
继续阅读→

text1 tex1t text1
继续阅读→

text2 text2 text2
继续阅读→


我不知道如何在jquery中执行此操作,您可以使用如下查找和替换方法:


您可以使用如下查找和替换方法:

$(“p”)。每个(函数(){
$(this.html(
$(this).html().replace(/\s继续\s读取\s→/G
“
继续阅读→")); });
$(“p”)。每个(函数(){
$(this.html(
$(this).html().replace(/\s继续\s读取\s→/G
“
继续阅读→")); });
您还可以使用CSS伪元素:

<p>text text text  <span></span>Continue reading →</p>

p span:before
{
     content : "\A";
     white-space : pre;
}
文本继续阅读→

p:之前 { 内容:“\A”; 空白:预处理; }

JQuery解决方案更安全,因为旧的IEs不支持::before,但是CSS解决方案不支持JS。

您也可以使用CSS伪元素:

<p>text text text  <span></span>Continue reading →</p>

p span:before
{
     content : "\A";
     white-space : pre;
}
文本继续阅读→

p:之前 { 内容:“\A”; 空白:预处理; }
JQuery解决方案更安全,因为旧IEs不支持::before,但是CSS解决方案在没有JS的情况下也可以工作