hi, I am using Bootstrap tab in project as Tab1 Tab2 Tab3
Tab 3 contains a button inside it, when any click event happens, it goes to Tab1 .
I want to keep Tab3 open when button is clicked inside it and should happen with respected tab if any event fires inside them.
Thank You
Naimish MakwanaPosted Mar 6, 2024, 7:35 AM
It sounds like you want to prevent the Bootstrap tab from switching when a button inside a tab is clicked. You can stop the event propagation when the button is clicked. Here’s an example using jQuery:
In this code,
$('.tab-pane button')selects the button inside your tab. Theclickfunction is an event handler that gets called when the button is clicked.e.stopPropagation();prevents the click event from bubbling up to the parent elements, which stops the tab from switching.Remember to replace
.tab-pane buttonwith the actual class or id of your button. If you have multiple buttons and only want this behavior for one of them, make sure to use a unique id or class for that button.Thanks
Abhishek YadavPosted Mar 6, 2024, 5:37 AM
Jignesh KumarPosted Mar 5, 2024, 4:12 AM
Hello Shusant,
You can use below one,
And Backend you need to set ActiveTab in controller setting up in ViewBag,