我正在使用这个 jQuery 插件:http://demo.awkwardgroup.com/showcase/
我试图在 Awkward Showcase 的第一张幻灯片上显示一个计数器,但无法在不破坏脚本的情况下将调用嵌套到脚本中。我尝试使用 current_id,但意识到 current_id 的值不一致,至少在我调用它时是这样。我现在尝试依赖数字 1 的“事件”状态,它对应于第一张幻灯片并且是一致的。
我现在意识到它有一个 custom_function 特性,但不知道如何将它插入那里
var awNavButtonID = document.getElementById('showcase-navigation-button-1');
function myHack() {
var awNavButtonClass = awNavButtonID.className;
if(awNavButton == 'active'){
document.getElementById('defaultCountdown').style.left = "250px";
} else {
document.getElementById('defaultCountdown').style.left = "-9999px";
}
}
$(document).ready(function(){
$("#showcase").awShowcase(
{
content_width: 700,
content_height: 470,
custom_function: null //how do i plug it in here?
});
});
最佳答案
如果你想将 myHack 函数绑定(bind)到 custom_function 回调,试试这个:
$("#showcase").awShowcase(
{
content_width: 700,
content_height: 470,
custom_function: myhack
});
您还可以将函数附加到局部变量。
var myHackFunction = function myHack() { ... }
...
custom_function: myHackFunction
最后,你可以实现一个匿名函数:
custom_function: function() { /* do stuff here */ }
关于javascript - 使用 jquery 脚本的自定义函数配置选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7058744/