如何使用jQuery删除标签和所述标签之间的所有文本?

Dav*_*d Z -3 html javascript css jquery

我有一些代码如下:

<p class="fp-excerpt fp-text-one  text-random-override">[image caption]I don't want this text[/image caption]Lorem Ipsum Text</p>

<p class="fp-excerpt fp-text-one  text-random-override">[image caption]I don't want the text here too[/image caption]Lorem Ipsum Text number two</p>
Run Code Online (Sandbox Code Playgroud)

如何使用jQuery定位段落类并删除[image caption]和[/ image caption]标签,以及中间的随机文本?

谢谢!

Ahs*_*s N 5

我就是这样做的:

$(".text-random-override").each(function(){
    $(this).html($(this).html().replace(/\[image caption\].+\[\/image caption\]/g,""));
});
Run Code Online (Sandbox Code Playgroud)

这是JSFiddle演示