search

Home  >  Q&A  >  body text

$(this).text()==="Show introduction" displays no instead of yes

<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>

        <script>

        $(function(){

            $("#btn").click(function(ev){

                if ($(this).text()==="显示简介") {

                    alert('yes');

                }else {

                    alert('no');

                }

            });

        })

        </script>

        </head>

    <body>

        <button id="btn">

            显示简介

        </button>

        <div id="ppt" style="display: none;">11111</div>

    </body>


图图图图2584 days ago1514

reply all(2)I'll reply

  • 路过

    路过2017-12-02 09:08:14

    1. Can there be branches inside the button?

    2. There is a big difference between "===" and "=="

    reply
    1
  • 图图

    Yeah, it’s true that buttons can’t be branched.

    图图 · 2017-12-02 21:18:25
  • Cancelreply