- jQuery-6ren"> - jQuery-这个问题已经有答案了: Find html element by content and hide using jQuery (6 个回答) 已关闭 5 年前。 正如您在图片中看到的,我有某种表格,我-6ren">
gpt4 book ai didi

javascript - 如果按钮包含 "sometext"如何隐藏
  • - jQuery
  • 转载 作者:行者123 更新时间:2023-12-03 02:04:32 25 4
    gpt4 key购买 nike

    enter image description here正如您在图片中看到的,我有某种表格,我需要用 jQuery 隐藏整个“< div >”,称为表格,如果里面的按钮“< div >”表示“询问”问题是我知道如何隐藏(实际上我希望它消失,我做到了),但是我不能做的部分是将button.ASKdiv.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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com