查找&;用jQuery替换特定的DIV

查找&;用jQuery替换特定的DIV,jquery,Jquery,我有一个我正在使用的页面,它有几个格式相同的隐藏DIV,但是每个DIV中的内容都不同。我希望能够找到一个特定的DIV(基于它的内容),取消隐藏它,并用自定义内容替换它 例如,我有: <div class="caption" style="display:none">[ProductDetail_Espot]</div> [ProductDetail\u Espot] 我想: <div class="caption" style=""><p>My

我有一个我正在使用的页面,它有几个格式相同的隐藏DIV,但是每个DIV中的内容都不同。我希望能够找到一个特定的DIV(基于它的内容),取消隐藏它,并用自定义内容替换它

例如,我有:

<div class="caption" style="display:none">[ProductDetail_Espot]</div>
[ProductDetail\u Espot]
我想:

<div class="caption" style=""><p>My Custom Content</p></div>
我的自定义内容

我看过一些正则表达式脚本之类的东西,但我不是一个脚本天才,所以任何帮助都将不胜感激

$(函数(){
$(function(){
    $(".caption:contains('Espot')).show().html('<p>My custom content</p>');
});
$(“.caption:contains('Espot')).show().html(“mycustomcontent

”); });
演示:

一些简单的jQuery,让您开始

$("#caption").show();
会显示出来,

$("#caption").html("<p>some html</p>");
$(“#caption”).html(一些html

”;

将替换内容。

如果您知道只有一个div包含此内容,则可以使用选择器:

$("#[ELEMENT ID]").click(function(){
$(".caption").show().html('[YOU NEW ACCONT]');
})
$('.caption:contains("[ProductDetail_Espot]")')
   .html("<p>My Custom Content</p>")
   .show();
$('.标题:包含(“[ProductDetail\u Espot]”)
.html(“我的自定义内容”

”) .show();
这是可行的,但为了澄清问题,我有20多个DIV带有.caption类。我只想将“[ProductDetail\u Espot]”作为其内容的DIV作为目标。