正如你在图像中看到的,我有一些表格,我需要隐藏整个“< div>”使用 jQuery 调用表格, if “< div>”内的按钮说“ ASK ” 事情是我知道如何隐藏(实际上我希望它消失,我完成了)但我不能做的部分是将 button.ASK 与 div.table
代码消除div:$("div.table").css("display", "none");
代码我需要修改:
<div class="_npuc5">
<div class="_f5wpw">
<a class="of_gvoze" href="Random_David" style="width: 30px; height: 30px;"><img class="_rewi8" src="http://es.horadeaventura.wikia.com/wiki/Archivo:AT_Icons_100x100_Jake.jpg">
</a>
<div class="_eryrc">
<div class="_2nunc">
<a class="_2g7d5w8" title="SOME TITLE HERE" href="ggggg.com/">RandomText</a>
</div>
<div class="Random_9mmn5">SOME TEXT HERE</div>
</div>
</div>
<div class="_mtnzs">
<span class="LLLL"><button class="askButton">ASK</button></span>
</div>
</div>
答案 0 :(得分:1)
您可以使用.filter()功能实现此目的:
$('#toggledisplay').click(function (){
//get all the list items
var lis = $('li');
//with the filter function, I can
//specify custom conditions
//to the elements I want to do something with
lis.filter(function (index){
// "this" is the current li on the loop.
//if the innertext of "this" equals "ask"
//then yes, this is the li I want
return $(this).text().trim() == "ASK";
}).toggle();
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li>ASK</li>
<li>nope</li>
<li>hey</li>
</ul>
<br>
<button id="toggledisplay"> Togggle the display of "ASK" </button>
&#13;
答案 1 :(得分:0)
您可以使用:contains()
Selector
window.onload = function() {
$("li:contains('ASK')").hide();
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li>One <button type="button">ASK</button>
<li>One <button type="button">REPLY</button>
<li>One <button type="button">REPLY</button>
<li>One <button type="button">REPLY</button>
</ul>
&#13;