开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜