admin管理员组文章数量:1400134
I've used jquery-ui tabs in a page. But I want, if someone clicks the link "Click me" in Tab1, it will automatically open the Tab2 for him. I want the link "Click me" to work as same as the Tab2 option works. How can I do that? My codes are given below
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Homepage</title>
<link rel="stylesheet" href="css/jquery_ui.css">
<link rel="stylesheet" href="css/index.css">
<script src="js/jquery.js"></script>
<script src="js/jquery_ui.js"></script>
<script>
$( function() {
$( "#tabs" ).tabs();
} );
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#tab_one">Tab1</a></li>
<li><a href="#tab_two">Tab2</a></li>
<li><a href="#tab_three">Tab3</a></li>
<div id="tab_one">
<p>Something about Tab1</p>
<p><a href="">Click me</a></p>
</div>
<div id="tab_two">
<p>Something about Tab2</p>
</div>
<div id="tab_three">
<p>Something about Tab3</p>
</div>
</ul>
</div>
</body>
</html>
I've used jquery-ui tabs in a page. But I want, if someone clicks the link "Click me" in Tab1, it will automatically open the Tab2 for him. I want the link "Click me" to work as same as the Tab2 option works. How can I do that? My codes are given below
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Homepage</title>
<link rel="stylesheet" href="css/jquery_ui.css">
<link rel="stylesheet" href="css/index.css">
<script src="js/jquery.js"></script>
<script src="js/jquery_ui.js"></script>
<script>
$( function() {
$( "#tabs" ).tabs();
} );
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#tab_one">Tab1</a></li>
<li><a href="#tab_two">Tab2</a></li>
<li><a href="#tab_three">Tab3</a></li>
<div id="tab_one">
<p>Something about Tab1</p>
<p><a href="">Click me</a></p>
</div>
<div id="tab_two">
<p>Something about Tab2</p>
</div>
<div id="tab_three">
<p>Something about Tab3</p>
</div>
</ul>
</div>
</body>
</html>
Share
Improve this question
asked Feb 20, 2017 at 10:51
Nahid SultanNahid Sultan
859 bronze badges
6 Answers
Reset to default 3use target="_blank"
attribute in your anchor tag, like
<li><a target="_blank" href="#tab_one">Tab1</a></li>
Maybe it will help you for custom click jquery-ui-tabs-with-nextprevious
$('#my-text-link').click(function() { // bind click event to link
$tabs.tabs('select', 2); // switch to third tab
return false;
});
Use this:
<p><a href="#tab_two">Click me</a></p>
You can set the id of tab two in href tag of anchor element.
<div><a href="#tab_two">Click here to open tab 2</a></div>
try this..
<li><a href="#" onclick="window.open('your_page.php','newwindow', config='height=700, width=1200, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, directories=no, status=no')" class="button yellow">Tab1</a></li>
using this link you can open new window with new page.
on the click event of the "Click me" button
Add the below code to acheive it.
$("a[href='#tab_two']").trigger("click");
This should work for you.
本文标签: javascriptHow to open another tab with a linkStack Overflow
版权声明:本文标题:javascript - How to open another tab with a link? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744200610a2594945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论