简体   繁体   English

带有jQuery ui的动态内容,唯一的选项卡处于活动状态

[英]Dynamic content with jQuery ui, unique tab active state

I would like to create a jQuery menu with dynamic content using the jQuery ui. 我想使用jQuery ui创建具有动态内容的jQuery菜单。

My question is, I have images for tabs, and each one is different, so each one's roll over is different, how could I design it to display each unique tab's active state when that specific tab is clicked? 我的问题是,我有一些用于选项卡的图像,并且每个图像都不相同,因此每个人的翻转都不相同,当单击该特定选项卡时,如何设计它以显示每个唯一选项卡的活动状态?

Thanx in advance! 提前感谢!

I would use CSS and load a stylesheet that replaces the styles for your tabs based on the classes given to them by the plugin when they are in various states, plus a unique class that you give them based on their content or position. 我将使用CSS并加载一个样式表,该样式表将根据插件在各种状态下提供给它们的类替换选项卡的样式,以及根据其内容或位置提供的唯一类。 Make sure that your stylesheet is loaded after the jQuery UI stylesheets. 确保在jQuery UI样式表之后加载样式表。 After the tabs are initialized, go through and assign the unique classes so that your CSS is applied. 初始化选项卡后,遍历并分配唯一的类,以便应用CSS。

.ui-tabs .ui-tabs-nav li.ui-tabs-selected.tab-0
{
    background-image: url(/images/selected-tab-0.png);
}


$(function() {
   $('.tabs').tabs();
   $('.tabs').find('li').each( function(i) {
       $(this).addClass( 'tab-' + i );
   });
});

Note that you could adjust the tab on load if the image needs to change based on the url that is chosen -- your class would just need to be dependent on your href -- by changing the class assigned based on the url being loaded. 请注意,如果图像需要根据所选的url进行更改,则可以调整加载选项卡-您的类仅需要依赖于href-通过更改基于要加载的url分配的类即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM