jQuery如何将第一个标签设置为活动状态? [英] jQuery how to set first tab active?

查看:146
本文介绍了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天全站免登陆