jQuery UI选项卡,单击其他选项卡时更新URL [英] jQuery UI tabs, update url when clicking on a different tab

查看:81
本文介绍了jQuery UI选项卡,单击其他选项卡时更新URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery UI的标签: http://jqueryui.com/demos/tabs/

I'm using the tabs of jQuery UI: http://jqueryui.com/demos/tabs/

当用户单击其他选项卡时,如何通过向其添加锚链接来更新浏览器的当前URL: ex:url.html#tab-4 并同时推送浏览器的当前历史记录.

How to update the current url of the browser when the user click on a different tab by adding the anchor link to it: ex: url.html#tab-4 and pushing the current history of the browser at the same time.

谢谢!

推荐答案

这应该得到您想要的(使用 jQuery UI 1.8 ,在1.9版及更高版本中,使用

This should get what you want (using jQuery UI 1.8, in version 1.9 and later use the activate event, see other answers for code example). I used the sample HTML in jQuery UI demos;

        $( "#tabs" ).tabs({
            select: function(event, ui) {                   
                window.location.hash = ui.tab.hash;
            }
        });

这篇关于jQuery UI选项卡,单击其他选项卡时更新URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆