折叠和扩展按钮在谷歌网站

collapse and expand button in a google site

本文关键字:谷歌 网站 按钮 扩展 折叠      更新时间:2023-09-26

我在一个谷歌网站工作,因为我认为它更容易…但是我遇到了一些麻烦。我想创建一个按钮,扩展和折叠文本块。我尝试了一些不同的选择,但我没有得到它。有人知道怎么做吗?

Thanks a lot

编辑:像这样:

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p").toggle();
    });
});
</script>
</head>
<body>
<button>Toggle between hiding and showing the paragraphs</button>
<p>This is a paragraph with little content.</p>
<p>This is another small paragraph.</p>
</body>
</html>
http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_toggle

例如,如果你可以使用JavaScript,你可以通过点击一个按钮将样式设置为"display:none;""display:block;"

<div id="ThisTextWillBeHidden">This text needs to be hidden</div>
<button type="button" 
onclick="document.getElementById("ThisTextWillBeHidden").style.display='none';">
    Click me to hide!
</button>
<button type="button" 
onclick="document.getElementById("ThisTextWillBeHidden").style.display='block';">
    Click me to show!
</button>

我假设Google Sites不支持脚本,因此您需要将此代码保存在其他地方,例如在您的主机或文件存储服务中,并像这样调用它:

<iframe src="location of the file containing your code.html"></iframe>