在 IE 11 中单击时无法显示多个工具提示

请帮助解决以下问题。我试图在单击按钮时显示多个工具提示,并在单击第二次按钮时隐藏它们。出于某种原因,我无法在 IE 11 中执行此操作。在我提供的示例中,默认情况下我可以在页面加载时完美显示它们。一旦我尝试在点击时执行此操作(代码被注释掉),什么也没有发生。


<!DOCTYPE html>

<html>

<head>

    <title>Bootstrap Example</title>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

<body>

    <div class="container">

        <h3>Demo</h3>

        <a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>


        <a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>

        <div>

            <button type="button" class="btn btn-primary">Show Tooltip</button>

            <button type="button" class="btn btn-default">Hide Tooltip</button>

        </div>

    </div>

    <script>

        //works fine  I can see tooltips by default

        $("[data-toggle='tooltip']").tooltip();

        $("[data-toggle='tooltip']").tooltip('show');


        $(document).ready(function () {

 

    $(".btn-primary").click(function () {

       //  doesn't work for some reson

      //  $("[data-toggle='tooltip']").tooltip();

       // $("[data-toggle='tooltip']").tooltip('show');

    });

    $(".btn-default").click(function(){

        $("[data-toggle='tooltip']").tooltip();

        $("[data-toggle='tooltip']").tooltip('hide');

    });

        });


      

           

        

    </script>

</body>

</html>


吃鸡游戏
浏览 174回答 1
1回答

婷婷同学_

<!DOCTYPE html><html><head>&nbsp; &nbsp; <title>Bootstrap Example</title>&nbsp; &nbsp; <meta charset="utf-8">&nbsp; &nbsp; <meta name="viewport" content="width=device-width, initial-scale=1">&nbsp; &nbsp; <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">&nbsp; &nbsp; <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>&nbsp; &nbsp; <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script></head><body>&nbsp; &nbsp; <div class="container">&nbsp; &nbsp; &nbsp; &nbsp; <h3>Demo</h3>&nbsp; &nbsp; &nbsp; &nbsp; <a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>&nbsp; &nbsp; &nbsp; &nbsp; <a href="#" data-toggle="tooltip" title="Tooltip is visible!">Tooltip will be visible here</a>&nbsp; &nbsp; &nbsp; &nbsp; <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <button type="button" class="btn btn-primary">Show Tooltip</button>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <button type="button" class="btn btn-default">Hide Tooltip</button>&nbsp; &nbsp; &nbsp; &nbsp; </div>&nbsp; &nbsp; </div>&nbsp; &nbsp; <script>&nbsp; &nbsp; &nbsp; &nbsp; //make sure to comment this lines&nbsp; &nbsp; &nbsp; &nbsp; //works fine&nbsp; I can see tooltips by default&nbsp; &nbsp; &nbsp; //&nbsp; $("[data-toggle='tooltip']").tooltip();&nbsp; &nbsp; &nbsp; &nbsp;// $("[data-toggle='tooltip']").tooltip('show');&nbsp; &nbsp; &nbsp; &nbsp; $(document).ready(function () {&nbsp;&nbsp; &nbsp; $(".btn-primary").click(function () {&nbsp; &nbsp; &nbsp; &nbsp; // works fine on IE11&nbsp; &nbsp; &nbsp; &nbsp; $("[data-toggle='tooltip']").tooltip();&nbsp; &nbsp; &nbsp; &nbsp; $("[data-toggle='tooltip']").tooltip('show');&nbsp; &nbsp; });&nbsp; &nbsp; $(".btn-default").click(function(){&nbsp; &nbsp; &nbsp; &nbsp; $("[data-toggle='tooltip']").tooltip();&nbsp; &nbsp; &nbsp; &nbsp; $("[data-toggle='tooltip']").tooltip('hide');&nbsp; &nbsp; });&nbsp; &nbsp; });&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; </script></body></html>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript