我已经设法基于矩阵中的一个指定数组(即数组中的数组)生成一系列列表项.
我希望能够将一个变量(表示一个数组)传递给一个函数,这样它就可以根据传入它的数组吐出一个填充了list-items的无序列表.
问题:
解决方案需要:
options[0],options[1]等)JavaScript的:
var options = [
set0 = ['Option 1','Option 2'],
set1 = ['First Option','Second Option','Third Option']
]
function makeUL(){
var a = '<ul>',
b = '</ul>',
m = [];
// Right now, this loop only works with one
// explicitly specified array (options[0] aka 'set0')
for (i = 0; i < options[0].length; i += 1){
m[i] = '<li>' + options[0][i] + '</li>';
}
document.getElementById('foo').innerHTML = a + …Run Code Online (Sandbox Code Playgroud) 我有一个多页表格.
我想在此表单的最后一页上执行一些自定义JavaScript.从理论上讲,我所要做的就是检索当前页码并编写条件.
简单吧?显然不是.
我原来的解决方法是这样的:
if ($('gform_page').last().css('display') !== 'none') {
// perform custom scripts now that the last
// Gravity Form page is being shown
}
Run Code Online (Sandbox Code Playgroud)
但$('...').css('display')回报率undefined在每一个元素我试过这个表单内.每次用户点击"下一步"按钮时,都会触发自定义脚本.没有雪茄.
然后,在查看Gravity Forms文档后,我发现了两个看似有用的事件:gform_post_render和gform_page_loaded.
但是,文档未提供有关如何访问参数的说明.
jQuery(document).bind('gform_page_loaded', function(event, form_id, current_page){
console.log(current_page);
// returns nothing when loaded in the footer
// returns [Object, object] when placed in an HTML field in the form
});
Run Code Online (Sandbox Code Playgroud)
除了没有正确的代码之外,我还怀疑我没有正确的代码,因为我还在functions.php和header.php中尝试了以下内容(如文档所示):
<?php
function enqueue_custom_script($form, $is_ajax){
if ($is_ajax) :
echo …Run Code Online (Sandbox Code Playgroud) 这里的目标是 1.gif 的 onclick,所有具有 .panel1 类的内容消失(style.display.none),并且所有具有 .panel2 类的内容都变得可见(style.display.inline)
我是新手......所以我认为这只是“ ”或“”的语法问题
<!DOCTYPE html>
<html>
<head>
<title>main</title>
<meta charset="utf-8">
<style type="text/css">
.panel1 {display:inline;}
.panel2 {display:none;}
</style>
<script type="text/javascript">
function panelTransition(panelOut,panelIn)
{
document.getElementByClass(panelIn).style.display="inline";
document.getElementByClass(panelOut).style.display="none";
}
</script>
</head>
<body>
<img class="panel1" src=1.gif onclick="panelTransition(panel1,panel2)" />
<img class="panel2" src=2.gif />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)