简体   繁体   English

如何在事件中使用javascript和jquery以编程方式从应用程序的当前选项卡切换到另一个选项卡

[英]How do I switch to another tab from current tab in the application programmatically using javascript and jquery on an event

I am using the tabs of jQuery UI 我正在使用jQuery UI的标签

How do I switch to another tab from current tab in the application pro-grammatically using javascript and jquery on an event eg click of button. 如何在事件(例如单击按钮)上使用javascript和jquery从应用程序的当前选项卡中以编程方式切换到另一个选项卡。

Due to security concerns it is not possible. 出于安全考虑,这是不可能的。 If by "tab" you mean a window and a popup window that opened up in a new tab. 如果使用“选项卡”,则表示在新选项卡中打开的窗口和弹出窗口。

window.opener.focus();

If you want to change to another tab in a Jquery UI tab by programmatically trigger the click event. 如果要通过编程触发click事件更改为Jquery UI选项卡中的另一个选项卡。

 $('#id_of_tab').click(); 

The jQuery UI Tabs use normal links to change the tabs. jQuery UI选项卡使用常规链接来更改选项卡。 So easiest way to change tab is just clicking the link (with javascript/jquery). 因此,更改标签的最简单方法是单击链接(使用javascript / jquery)。 Say the link in your tab has an id like this: 假设标签中的链接具有如下所示的ID:

<div id="tabs">
  <ul>
    <li><a href="#tabs-1" id="tab-1">Nunc tincidunt</a></li>
    <li><a href="#tabs-2" id="tab-2">Proin dolor</a></li>
    <li><a href="#tabs-3" id="tab-3">Aenean lacinia</a></li>
 </ul>

If you want to change to tab 2 you can use $('#tab-2').click(); 如果要更改为选项卡2,可以使用$('#tab-2')。click();。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 javascript 和 jquery 以编程方式从主选项卡切换到辅助选项卡 - How do I programmatically toggle from a primary tab to a secondary tab using javascript and jquery 如何使用 jQuery,java 脚本从一个选项卡切换到另一个选项卡? - How to switch from one to another tab using jQuery,java script? 我想在javascript中当前选项卡的最后一个元素上将一个选项卡切换到另一个选项卡 - I want to switch one tab to another tab on last element of current tab in javascript 如何使用jQuery / Javascript将事件从标签/窗口发送到另一个 - How to send an event from a tab/window to another with jQuery/Javascript 使用jQuery,如何在当前标签上禁用点击效果? - Using jQuery, how do I disable the click effect on the current tab? 如何使用具有相同来源的 JavaScript 以编程方式切换到特定的浏览器选项卡? - How to switch to a specific browser tab programmatically using JavaScript with same origin? 如何从另一个页面链接到特定的javascript标签? - How do I link to a specific javascript tab from another page? 如何使用Javascript刷新另一个选项卡 - How can I refresh a tab from another using Javascript 不要在标签点击事件上切换标签 - Do not switch tab on tab click event 如何使用 javascript 或 jquery 关闭当前窗口或选项卡 - How to close current window or tab using javascript or jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM