最初隐藏时,ShareThis无法正确显示

时间:2019-05-31 18:22:31

标签: jquery hide sharethis

如何在单击“显示”按钮后正确显示ShareThis按钮?按下“显示”按钮后,所有“ .st-btn”都具有“显示:无”,直到我调整窗口大小并自动变为“显示:内联块”为止。换句话说,ShareThis仅能正确显示在按下“显示”按钮并手动调整窗口大小之后。预先谢谢你

$('span').hide();
$('button').click(function(){$('span').show();});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://platform-api.sharethis.com/js/sharethis.js#property=58ff3bc2a9dabe0012b03357&product=inline-share-buttons"></script>

<button>show</button>
<span><div class="sharethis-inline-share-buttons"></div></span>

sample code

1 个答案:

答案 0 :(得分:1)

要解决您的问题,只需将其更改为:

$('span').show();

收件人:

$('span').find(':hidden').addBack().show();

显示span元素及其下的所有隐藏元素。

代码(jsfiddle here)

$('span').hide();
$('button').click(function () {
    $('span').find(':hidden').addBack().show();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://platform-api.sharethis.com/js/sharethis.js#property=58ff3bc2a9dabe0012b03357&product=inline-share-buttons"></script>


<button>show</button>

<span><div class="sharethis-inline-share-buttons"></div></span>