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

Jignesh KumarRank #91 · 22.9K reputationPosted Mar 4, 2024, 11:12 PM EST
Hello Shusant,
You can use below one,
And Backend you need to set ActiveTab in controller setting up in ViewBag,
public ActionResult Index() { //Set the active tab based on Your code logic, How you want to make it ViewBag.ActiveTab = "Tab3"; return View(); }Abhishek YadavRank #217 · 11.3K reputationPosted Mar 6, 2024, 12:37 AM EST
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 6, 2024, 2:35 AM EST
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:
$(document).ready(function(){ $('.tab-pane button').click(function(e){ e.stopPropagation(); }); });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