简体   繁体   English

如何克隆div并使用regEx而不再次克隆?

[英]How can I clone a div and use an regEx without cloning again?

I'm kinda stuck. 我有点卡住了。

I'm cloning the content of a p- and ul- element 我正在克隆p和ul元素的内容

var abc = $("div p,div ul").clone();

I want to change the output with a regEx replace(). 我想用regEx replace()更改输出。

It looks like 看起来像

abc.html(abc.html().replace(/myReplace/, '$1'));

My problem is the output. 我的问题是输出。 html-structur without html-结构没有

abc.html(abc.html().replace(/myReplace/, '$1'));

<p>Content</p>
<ul<
   <li>P1</li>
   <li>P2</li>
   <li>P3</li>
</ul>

html-structur with html-结构与

abc.html(abc.html().replace(/myReplace/, '$1'));

<p>Content</p>
<ul>
<p>Content</p>
</ul>

How can I clone a div and replace some numbers later on without cloning again? 如何克隆div并在以后替换某些数字而又不进行克隆?

'abc' is not a function. 'abc'不是函数。 It is the resulting jQuery collection from the operations performed in the first line. 它是第一行中执行的操作所得的jQuery集合。 Use of 'abc' thereafter does not cause more cloning. 此后使用'abc'不会导致更多克隆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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