【发布时间】:2014-11-25 14:59:37
【问题描述】:
我在对话框中使用手风琴来完成最终用户需要执行的不同步骤。每个步骤都有一个按钮或带有按钮的文本框。我怎样才能得到它,以便当用户按下回车键时,它会激活与活动标题关联的按钮。
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<div id="accordion">
<h3 id="Step1">Step 1:</h3>
<div>
<p>
To get started click "Setup" and it will configure this spreadsheet for use with the Connected Groups Add-on.
</p>
<p><button id="Step1B" class="action" onclick="step1()">Setup</button></p>
</div>
<h3 id="Step2">Step 2</h3>
<div>
<p>
To get started enter the name of your first contact group below then click "Create".
</p>
<p><input type="text" id="gName">
<button id="Step2B" class="action" onclick="step2()">Create</button></p>
</div>
<h3 id="Step3">Done</h3>
<div>
<p><center>
Thank you for using Connected Groups. More information or help can be found:
</center>
</p>
<p><button id="thankYou" onclick="step3()">Close</button></p>
</div>
</div>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(function() {
$( "#accordion" ).accordion({
heightStyle: "content"
});
}); // run on launch
function step1(){
alert("Step1");
$('#Step2').click();
};
function step2(){
var tb = $("#gName").val();
alert("Step2: "+tb);
$('#Step3').click();
};
function step3(){
google.script.host.close();
};
</script>
【问题讨论】:
-
这实际上是使用 htmlService 的较大 App 脚本的一部分。我只是将其修剪以仅显示相关代码。对于拿走标签的管理员,我想保留它,因为 HtmlService 依赖于 Caja,这是非常有限的,可能会影响答案。
-
@Mogsdad 是的,我知道那部分来自 GAS,但我认为他的问题出在 javascript 或 jQuery 上,因此只要他的服务器端 GAS 脚本工作正常,就不需要该标签。但不管怎样,我就是这么想的。你可以留着。干杯。
-
您是否只是想在按钮单击时打开下一个手风琴......?如果是这样,可能有更好的方法来做到这一点。
-
@TJ 我已经解决了下一个问题(点击),我只是不知道如何让它在 Enter 上工作。
标签: javascript jquery jquery-ui google-apps-script