Getting Target URL from jQuery-UI Tabs

跟風遠走 提交于 2019-11-30 22:28:51

The following will write out the href's to the console.

Demo that alerts the ajax tab href's here

$('#tabs a').each(function() {
   var href = $.data(this, 'href.tabs');
   console.log(href);
})
var links = $("#thetabs > ul").find("li a");
var url = $.data(links[tabnum], 'href.tabs');

tabnum is the zero based index of the tab you want the url from

You can also set the title property in the tab links.

<div id="tabs">
    <ul>
        <li><a href="tab1.html" title="First tab contents">tab1</a></li>
        <li><a href="tab2.html" title="Second tab contents">tab2</a></li>
        <li><a href="tab3.html" title="Third tab contents">tab3</a></li>
    </ul>
</div>

With this, JQueryUI will create divs with an id based on the title, with the spaces replaced by underscores, therefore you should be able to access the divs using something like

$("#First_tab_contents")

Cheers!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!