jQuery如何设置第一个选项卡处于活动状态? [英] jQuery how to set first tab active?

查看:13
本文介绍了jQuery如何设置第一个选项卡处于活动状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 $( '#xxx' ).tabs({
select: function(event, ui) { 
var theSelectedTab2 = ui.index;

if (theSelectedTab2  == 0) {
$('ul li.ep_s1').removeClass('ep_s1').addClass('ep_s-click1');
if ($('ul li#h13').hasClass('ep_l-click1')) {
   $('ul li#h13').removeClass('ep_l-click1').addClass('ep_l1');
}}
else if (theSelectedTab2  == 1 ) {
$('ul li.ep_l1').removeClass('ep_l1').addClass('ep_l-click1');
if ($('ul li#h12').hasClass('ep_sidebar_friends-click1')) {
   $('ul li#h12').removeClass('ep_s-click1').addClass('ep_s1');
}}
 }
}); 

如果我使用 selected: 0 它会将第一个选项卡设置为活动状态,但现在它将通过 if (theSelectedTab2 == 0) 语句并通过添加这些类.

if i use selected: 0 it will set up the first tab as active but it will now go through the if (theSelectedTab2 == 0) statement and go through adding those classes.

如果页面加载后我点击这些标签,脚本就可以完美运行.

if after the page loads i click on those tabs the script works perfect.

基本上我希望页面加载 if (theSelectedTab2 == 0) 语句以及其中发生的所有事情都处于活动状态.

basically i want when the page loads the if (theSelectedTab2 == 0) statement and everything that happens inside it to be active.

谢谢

推荐答案

页面加载后第一个标签触发点击事件?

Trigger a click event on the first tab after page load?

点赞 $('first tab selector').click()

这篇关于jQuery如何设置第一个选项卡处于活动状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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