【发布时间】:2015-10-22 17:06:18
【问题描述】:
我正在尝试在我的网页中嵌入一个小型鼠尾草细胞/程序。但是,该单元仅在用户按下激活按钮时激活。我希望单元格自动显示在页面上,这样用户就不必按下激活按钮,然后为程序输入值。我不知道我怎么能做到这一点。他们有什么方法可以自动按下由脚本创建的按钮吗?他们有什么办法让单元格出现吗?
这里是源代码:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Sage Cell Server</title>
<script src="https://sagecell.sagemath.org/static/jquery.min.js"></script>
<script src="https://sagecell.sagemath.org/static/embedded_sagecell.js"></script>
<script>$(function () {
// Make the div with id 'mycell' a Sage cell
sagecell.makeSagecell({inputLocation: '#mycell',
template: sagecell.templates.minimal,
evalButtonText: 'Activate'});
hide: ['evalButton']
// Make *any* div with class 'compute' a Sage cell
});
</script>
</head>
<body>
<h2>Factorial</h2>
Click the “Activate” button below to calculate factorials.
<div id="mycell">
@interact
def _(a=(1, 10)):
print factorial(a)
</script>
</div>
</body>
</html>
这是生成的按钮的html:
<button type="button" class="sagecell_evalButton ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Activate</span></button>
【问题讨论】:
-
你能在 jsfiddle 上复制同样的内容吗,jsfiddle.net