[英]Jquery tabs, how to redirect?
Hello all you programmers, well I have one problem with jQuery tabs. 各位程序员大家好,我对jQuery选项卡有一个问题。 I am using jQuery for navigation between tabs, and jQuery code looks like this:
我使用jQuery在选项卡之间导航,jQuery代码如下所示:
$(document).ready(function() {
//Default Action
$(".tab-content").hide(); //Hide all content
$("ul.vertical-tab li:first").addClass("active").show(); //Activate first tab
$(".tab-content:first").show(); //Show first tab content
//On Click Event
$("ul.vertical-tab li").click(function() {
$("ul.vertical-tab 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;
});
});
First tab is always default, so when I work on second tab, and submit data to external php script, redirection always returns me on the first(default tab). 第一个选项卡始终是默认选项,因此当我在第二个选项卡上工作并将数据提交到外部php脚本时,重定向总是在第一个选项卡上返回(默认选项卡)。 My redirection looks like this: header('Location: http://www.administrator.php ');
我的重定向如下所示: header('Location: http://www.administrator.php ');
$con=mysqli_connect("localhost","root","","database");
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$sql="INSERT INTO student (firstname,lastname) VALUES('$firstname','$lastname')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error());
}
header('Location:http://www.administrator.php');
mysqli_close($con);
So because I use jQuery I can't redirect myself to desired tab using address. 因为我使用jQuery,我无法使用地址将自己重定向到所需的选项卡。 Help :/
救命 :/
You could do a hash-based lookup such as: 您可以执行基于哈希的查找,例如:
link: http://www.administrator.php/#secondtab
$firsttab = window.location.hash ?
$(window.location.hash) :
$("ul.vertical-tab li:first");
$.firsttab.addClass('active').show();
Then you just need Ids for your tabs to match (eg id="secondtab"
) 然后你只需要你的标签的ID匹配(例如
id="secondtab"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.