如何将函数传递给jquery ui tabs active option?
我可以像这样将函数传递给jquery uim选项卡激活选项
activate: function(event, ui){
localStorage.setItem("#" + $(this).context.id + "-current-index", $(this).tabs('option', 'active'));
}
如何使用活动选项获取这些值,下面的代码不起作用
active: function(event, ui){
localStorage.getItem("#" + $(this).context.id + "-current-index")
}
您可能需要查看.getItem()
。我建议如下:
function getData(i){
return localStorage.getItem(i);
}
然后你可以像这样使用它:
active: function(event, ui){
ui.newPanel.html(getData("#" + $(this).context.id + "-current-index"));
}
更新
激活( 事件, UI (类型: 选项卡激活
激活选项卡后(动画完成后(触发。如果选项卡以前是折叠的,则
ui.oldTab
和ui.oldPanel
将是空的 jQuery 对象。如果选项卡折叠,则ui.newTab
和ui.newPanel
将是空的jQuery对象。
另请参阅: https://api.jqueryui.com/tabs/#event-activate
ui.newPanel
是jQuery对象,它表示">刚刚激活的面板。"因此,我们可以在该对象上使用.html()
。
.html( htmlString (
说明:设置匹配元素集中每个元素的 HTML 内容。
另请参阅: https://api.jquery.com/html/