我知道这个具体的问题是asked before,但是我在jQuery UI Tabs插件上使用bind()事件没有得到任何结果.

I just need the index of the newly selected tab to perform an action when the tab is clicked. bind() allows me to hook into the select event, but my usual method of getting the currently selected tab does not work. It returns the previously selected tab index, not the new one:

var selectedTab = $("#TabList").tabs().data("selected.tabs");

Here is the code I am attempting to use to get the currently selected tab:

$("#TabList").bind("tabsselect", function(event, ui) {

});

When I use this code, the ui object comes back 100.从文档来看,这应该是我用来使用ui连接到新 Select 的索引的对象.标签.我在最初的tabs()通话中try 过这个,也try 过它自己.我做错什么了吗?

推荐答案

For JQuery UI versions before 1.9: ui.index from the event is what you want.

For JQuery UI 1.9 or later: see the answer by Giorgio Luparia, below.

Jquery相关问答推荐

从文本区域获取值

jQuery在页面加载 timeshift 动到锚点位置

如何使用 jquery 获取屏幕的高度

使用 jQuery 时何时/为什么要在变量前加上$?

如何滚动到jQuery中的元素?

jQuery中的正则表达式字段验证

为什么我们在 jQuery 中使用({ })?

如何在单击时 Select 多选 Select 框的所有选项?

jQuery Select 一个具有某个类的div,它没有另一个类

如何禁用在div内单击

jQuery UI 滑块(以编程方式设置)

如何在 JQuery DataTable 中默认显示所有行

未捕获的语法错误:无法在文档上执行querySelector

jQuery .load() 调用不会在加载的 HTML 文件中执行 JavaScript

如何使用jQuery在弹出窗口中预览输入类型=文件中的选定图像?

停止输入/书写后如何触发输入文本中的事件?

通过单击按钮获取表格行的内容

如何重新加载/刷新 jQuery 数据表?

添加到数组 jQuery

jQuery,简单的轮询示例