我使用过JQuery UI标签,我的标签工作正常。请参阅下面的代码。
<ul class="tabs">
<li><a href="#tab1">Login</a></li>
<li><a href="#tab2">Register User</a></li>
<li><a href="#tab3">Forgot Password </a></li>
</ul>
<div class="tab_container">
<div id="tab1" class="tab_content clearfix">
<h2>Login</h2>
<div class="login-form">
<div class="username-bg"><input name="a" type="text" value="username" /><img src="images/user-icon.png" alt="" /></div>
<div class="password-bg"><input name="a" type="password" value="password" /><img src="images/password-icon.png" alt="" /></div>
<a href="#tab3" class="login-text">Lost Your Password ?</a>
<a href="preprints.html" class="signup"></a>
</div>
</div>
<div id="tab2" class="tab_content ">
<h2>Register User</h2>
<div class="login-form">
<div class="username-bg " ><input name="a" type="text" value="username" required /><img src="images/user-icon.png" alt="" /></div>
<div class="password-bg"><input name="a" type="password" value="password" /><img src="images/password-icon.png" alt="" /></div>
<a href="#tab3" class="login-text">Lost Your Password ?</a>
<a href="preprints.html" class="save"></a>
</div>
</div>
<div id="tab3" class="tab_content">
<h2>Forgot Password</h2>
<div class="login-form">
<div class="username-bg"><input name="a" type="text" value="new password" /><img src="images/password-icon.png" alt="" /></div>
<div class="password-bg"><input name="a" type="text" value="confirm password" /><img src="images/password-icon.png" alt="" /></div>
<a href="#tab3" class="login-text">Lost Your Password ?</a>
<a href="preprints.html" class="save"></a>
</div>
</div>
</div>
我使用的Jquery是
<script type="text/javascript">
$(document).ready(function() {
//Default Action
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab
$(".tab_content:first").show(); //Show first tab content
//On Click Event
$("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
});
</script>
现在我想要一个标签Lost Your Password ?
内的链接链接到tab3,忘记密码标签,但它不是请求帮助。感谢
答案 0 :(得分:0)
为标签内的链接指定一个新类(例如class="linktab"
)和一个数据属性(例如data-tab="3"
)并使用类似
$('a.linktab').click(function() {
$('.tabs').tabs('option', 'active', $(this).data('tab'));
return false;
});