Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.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
Javascript 当子div与父div之间存在多个w.r.时,删除子div_Javascript_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

Javascript 当子div与父div之间存在多个w.r.时,删除子div

Javascript 当子div与父div之间存在多个w.r.时,删除子div,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,我有两个动态创建的div,如下所示: message.txt testcase.txt message.txt testcase.txt 。列表组项有多个,因此您需要在其上循环 $('#starredList').children('.list-group-item').each(function(){ if($(this).children('.a-file').text() == file){ $(this).remove(); } }); 。列表组项有多个,因此您需

我有两个动态创建的div,如下所示:


message.txt
testcase.txt
message.txt
testcase.txt

。列表组项有多个,因此您需要在其上循环

$('#starredList').children('.list-group-item').each(function(){
  if($(this).children('.a-file').text() == file){
     $(this).remove();
  }
});

。列表组项
有多个,因此您需要在其上循环

$('#starredList').children('.list-group-item').each(function(){
  if($(this).children('.a-file').text() == file){
     $(this).remove();
  }
});
这应该可以做到

var file = $(this).closest('.list-group-item').children('.a-file').text();

$('.list-group-item').not($(this).closest('.list-group-item')).each(function(){
   if($(this).find('.a-file:contains('+file+')').length > 0){
       $(this).remove();
   }
});
这应该可以做到

var file = $(this).closest('.list-group-item').children('.a-file').text();

$('.list-group-item').not($(this).closest('.list-group-item')).each(function(){
   if($(this).find('.a-file:contains('+file+')').length > 0){
       $(this).remove();
   }
});