Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery匹配唯一类名_Jquery_Unique_Match_Classname - Fatal编程技术网

jquery匹配唯一类名

jquery匹配唯一类名,jquery,unique,match,classname,Jquery,Unique,Match,Classname,我正在尝试使用jquery在wordpress的滑块中获得评论。我绝对不是专家,所以我请求一些帮助。这是我到目前为止所拥有的 <div id="slider-1> <div id="content-805">content here</div> <div id="comments-wrap-805" class="comments-805"> //Parent <div id="commentform-798" class="comments

我正在尝试使用jquery在wordpress的滑块中获得评论。我绝对不是专家,所以我请求一些帮助。这是我到目前为止所拥有的

<div id="slider-1>
<div id="content-805">content here</div>
<div id="comments-wrap-805" class="comments-805"> //Parent
<div id="commentform-798" class="comments-798">comment stuff</div> //child
<div id="commentform-605" class="comments-605">comment stuff</div> //child
<div id="commentform-735" class="comments-735">comment stuff</div> //child
<div id="commentform-425" class="comments-425">comment stuff</div> //child
<div id="commentform-810" class="comments-810">comment stuff</div> //child
</div>
</div>

干杯你可以这样做

$.each($("div[id^='comments-wrap']"),function(){ // this will fetch all parent div's
    var CurrectDiv=$(this);
    CurrectDiv.find('div').filter(function(){
        if($(this).attr('class')==CurrectDiv.attr('class'))
        {
           $(this).hide(); 
        }
     });
});

$.each($("div[id^='comments-wrap']"),function(){ // this will fetch all parent div's
    var CurrectDiv=$(this);
    CurrectDiv.find('div').filter(function(){
        if($(this).attr('class')==CurrectDiv.attr('class'))
        {
           $(this).hide(); 
        }
     });
});