Twitter 分享按钮(小部件)无法使用 Firefox 中的 jquery 淡出功能

Twitter share button (widget) not working with jquery fadeout function in firefox

我使用的是 firefox 50.1.0,当我添加 fadeout 或 fadein jquery 功能时,Twitter 分享按钮没有显示。 iframe 正在加载,但按钮未显示。该按钮在除 FIREFOX 之外的所有浏览器中都可以正常工作。 这是我的 fiddle https://jsfiddle.net/trvh8r12/

<!DOCTYPE html>
<html >
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">

</head>
<body>
    <div class="container" id="form-puzzle">


        <div class="col-md-12 text-align">
                <button class="btn btn-success btn-md btn-margin" type="submit" id="btn-submit">Submit</button>
        </div>
    </div>
    <div class="container" id="message-id">
            <div class="row">
                    <div class="col-md-12 text-center message-color">
                            <h1>Congrats !!!!!....</h1>
                    </div>
                    <div class="col-md-12 text-align" style="display:block !important;">
                                <div class="gap"></div>

                        <a href="https://twitter.com/share" class="twitter-share-button btn-icon" data-text=" "
                     data-show-count="false"><i class="btn-icon"></i></a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
                 </div>
            </div>
    </div>
    <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

    <script>
            $(document).ready(function(){
                    $('#message-id').hide();
                    $('#btn-submit').click(function(){
                            $('#message-id').fadeIn(2000);
                            $('#form-puzzle').fadeOut(2000);
                    });
            });
    </script>
</body>
</html>

通常,将您的脚本引用保留在头部而不是正文中。您需要正确包含 jQuery、Bootstrap、css 和 Bootstrap js 才能使用它。这是通过单击获取小部件脚本,然后使用小部件代码扫描 dom 以查找 div 来执行的,以解决 Firefox 的异步问题。

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> Code Integration Close
    <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <!-- Latest compiled and minified JavaScript -->
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

    <title>Home</title>
</head>

<body>
    <div class="container" id="form-puzzle">


        <div class="col-md-12 text-align">
            <button class="btn btn-success btn-md btn-margin" type="submit" id="btn-submit">Submit</button>
        </div>
    </div>
    <div class="container" id="message-id">
        <div class="row">
            <div class="col-md-12 text-center message-color">
                <h1>Congrats !!!!!....</h1>
            </div>
            <div class="col-md-12 text-align" style="display:block !important;">
                <div class="gap"></div>
                <a href="https://twitter.com/share" class="twitter-share-button" data-show-count="false">Tweet</a>
            </div>
        </div>
    </div>

    <script>
        $(document).ready(function() {
            $('#message-id').hide();
            $('#btn-submit').click(function() {
                $.getScript("https://platform.twitter.com/widgets.js")
                    .done(function() {
                        $('#message-id').show(function() {
                            $('#form-puzzle').fadeOut(2000);
                            twttr.widgets.load(
                                document.getElementById("#message-id")
                            );
                        });
                    })
            });
        });
    </script>

</body>

</html>