折叠和展开谷歌网站中的按钮

时间:2016-10-31 11:22:53

标签: javascript html google-sites

我在谷歌网站上工作,虽然它更容易......但我有一些麻烦。我想创建一个展开和折叠文本块的按钮。我尝试了一些不同的选择,但我没有得到它。有谁知道怎么做?

非常感谢

编辑:这样的事情:

<!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

1 个答案:

答案 0 :(得分:1)

例如,如果您可以使用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协作平台不支持脚本,因此您需要将此代码保存在其他位置,例如托管或文件存储服务,并将其称为:

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