Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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 - Fatal编程技术网

Jquery-父选择器(最近的)

Jquery-父选择器(最近的),jquery,Jquery,如何从父类中选择父类 js <div onclick="$('.al_head.tt_this).closest('.aledmsg').remove();" style="cursor:pointer;"> TEST </div> 测试 html <div id="albox"> <div class="al_head" style="margin-bottom: 5px;" id="alss"> <img src="bt

如何从父类中选择父类

js

<div onclick="$('.al_head.tt_this).closest('.aledmsg').remove();" style="cursor:pointer;"> TEST </div> 
测试
html

<div id="albox">

    <div class="al_head" style="margin-bottom: 5px;" id="alss"> <img  src="bt.png" alt="se">
    <div style="float: left; width: 282px;" class="aledmsg"><strong>Feexts</strong>
      <hr>
      <div class="ams" id="xc98f">blub</div>
      <div class="ams tt_this" id="xb697">blib <-</div>
      <div class="ams" id="x56b1">blab</div>
      <div class="ams tt_this" id="xb214">blnb <-</div>
       <div class="ams tt_this" id="xb997">blmb <-</div>      
    </div>
  </div>
           <br />   <br />
    <div class="al_head_2" style="margin-bottom: 5px;" id="alss"> <img  src="bt.png" alt="se">
    <div style="float: left; width: 282px;" class="aledmsg_2"><strong>Feexts 2</strong>
      <hr>
      <div class="ams" id="xc98f">blub</div>
      <div class="ams tt_this" id="xb697">blib <-</div>
      <div class="ams" id="x56b1">blab</div>
      <div class="ams tt_this" id="xb214">blnb <-</div>
       <div class="ams tt_this" id="xb997">blmb <-</div>      
    </div>
  </div>

</div>

Feexts

布鲁布 blib我想这就是你想要的:

$('#albox .tt_this').closest('.aledmsg').remove();

,在初始选择器和
上的引号不匹配。tt\u这个
类在一个孩子身上,而不是直接在
\albox上
啊,好的,我明白了。非常感谢你,尼克!