正如您在图片中看到的,我有某种表格,我需要用 jQuery 隐藏整个“< div >”,称为表格,如果里面的按钮“< div >”表示“询问” 问题是我知道如何隐藏(实际上我希望它消失,我做到了),但是我不能做的部分是将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>
最佳答案
您可以使用 .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();
});
<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>
关于javascript - 如果按钮包含 "sometext"如何隐藏 <li> - jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49859930/