How to switch among tab-breaks using JS?

For example, I have five tab-breaks in my form, and I want to switch among them using JavaScript code.

One way is to scroll to any field or first field in the tab you want to switch to

frm.scroll_to_field(fieldname);

or

you can trigger click event on particular tab.
E.g.
Tab name is form_settings_tab
id = <doctype-name>-<tab-name>-tab

$("#web-form-form_settings_tab-tab").trigger("click")

1 Like

if you have access to the docfield that is tab then you can also just call docfield.tab.set_active()

1 Like

thank you for your reply, both methods work fine.
In my opinion, triggering the click event is more efficient.
But I have found that adding the <doctype-name> does not work.
It simply works with $("#user-<field-name>-tab").trigger("click") where field-name is the field-name of the Tab-Break field

1 Like

thank you for your reply, but unfortunately, I have found the followings:
docfield.tab.set_active() throws ReferenceError: <docfield> is not defined
frm.docfield.tab.set_active() or frm.fields_dict.docfield.tab.set_active() throws TypeError: Cannot read properties of undefined (reading 'tab')

Frappe Framework: v14.x.x-develop () (develop)