开发者

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

开发者 https://www.devze.com 2023-02-17 20:20 出处:网络
I\'m kinda stuck. I\'m cloning the content of a p- and ul- element var abc = $("div p,div ul").clone();

I'm kinda stuck.

I'm cloning the content of a p- and ul- element

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

I want to change the output with a regEx replace().

It looks like

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

My problem is the output. html-structur without

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

<p>Content</p>
<ul<
   <li>P1</li>开发者_运维技巧
   <li>P2</li>
   <li>P3</li>
</ul>

html-structur with

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?


'abc' is not a function. It is the resulting jQuery collection from the operations performed in the first line. Use of 'abc' thereafter does not cause more cloning.

0

精彩评论

暂无评论...
验证码 换一张
取 消