让 google +1 按钮像父 div 一样隐藏
我有一个模态框 div,其可见性:隐藏; 5 秒后,由于 JavaScript 函数的作用,它就显示出来了。在该 div 内,我有 google plus 一个按钮的代码,但问题是在弹出模式框之前,该按钮已经可见。我希望它与模式框同时出现(页面加载后 5 秒,而不是立即)。有什么办法可以做到这一点吗?
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<g:plusone size="tall" callback="g_click_function"></g:plusone>
<script>
function g_click_function(){
document.getElementById('greet_block_close').click();
}
</script>
I have a modal box div, that has visibility: hidden; and after 5s it shows up thanks to a javascript function. Inside that div, I have code for google plus one button, but the thing is that before the modal box pops up, the button is already visible. I want it to appear at the same time as the modal box (5s after the page loads, not instantly). Is there any way to do that?
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
<g:plusone size="tall" callback="g_click_function"></g:plusone>
<script>
function g_click_function(){
document.getElementById('greet_block_close').click();
}
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,向
标记添加一个 id,例如
mygone
:然后,如果您使用 jQuery(或正文的 onload),则在页面加载:
最后,当您准备好显示它时,运行此代码:
我还在 JSFiddle 中为您创建了一个示例: http://jsfiddle.net/EDTdY/2/。
First, add an id to the
<script>
tag, such asmygone
:Then, if you're using jQuery (or onload for the body) hide it when the page loads:
Finally, when you're ready to show it, run this code:
I also created an example in JSFiddle for you here: http://jsfiddle.net/EDTdY/2/.