How to close tabs in bootstrap: 1. Introduce jquery; 2. Reference the "bootstrap-closable-tab" plug-in in the corresponding page; 3. Pass "closeTab:function(item){...}" This method can achieve the effect of closing tabs.
#The operating environment of this article: Windows7 system, bootstrap3, Dell G3 computer.
Bootstrap comes from Twitter and is currently the most popular front-end framework. Bootstrap is based on HTML, CSS, and JavaScript, and it is simple and flexible. During the development process, we only need to add the corresponding class to the DOM element to call it, making Web development faster.
How can bootstrap close tabs?
I found a tab plug-in that can be closed from the Internet: bootstrap-closable-tab plug-in
Reference the bootstrap-closable-tab plug-in in the page to achieve closeability tab page effect.
1. The bootstrap-closable-tab component is a component that can close tab tabs. It is based on jquery and bootstrap; therefore, bootstrap related plug-ins must be introduced.
The prerequisite is to introduce jquery:
2. Introduce the plug-in:
The code is as follows:
//子页面不用iframe,用div展示 var closableTab = { //添加tab addTab:function(tabItem){ //tabItem = {id,name,url,closable} var id = "tab_seed_" + tabItem.id; var container ="tab_container_" + tabItem.id; $("li[id^=tab_seed_]").removeClass("active"); $("div[id^=tab_container_]").removeClass("active"); if(!$('#'+id)[0]){ var li_tab = '<li role="presentation" class="" id="'+id+'"><a href="#'+container+'" role="tab" data-toggle="tab" style="position: relative;padding:2px 20px 2px 15px">'+tabItem.name; if(tabItem.closable){ li_tab = li_tab + '<i class="glyphicon glyphicon-remove small" tabclose="'+id+'" style="position: absolute;right:4px;top: 4px;" οnclick="closableTab.closeTab(this)"></i></a></li> '; }else{ li_tab = li_tab + '</a></li>'; } var tabpanel = '<div role="tabpanel" class="tab-pane" id="'+container+'" style="width: 100%;">'+ '正在加载...'+ '</div>'; $('.nav-tabs').append(li_tab); $('.tab-content').append(tabpanel); $('#'+container).load(tabItem.url,function(response,status,xhr){ if(status=='error'){//status的值为success和error,如果error则显示一个错误页面 $(this).html(response); } }); } $("#"+id).addClass("active"); $("#"+container).addClass("active"); }, //关闭tab closeTab:function(item){ var val = $(item).attr('tabclose'); var containerId = "tab_container_"+val.substring(9); if($('#'+containerId).hasClass('active')){ $('#'+val).prev().addClass('active'); $('#'+containerId).prev().addClass('active'); } $("#"+val).remove(); $("#"+containerId).remove(); } }
3. HTML code:
<div class="iframe_div_wrap"> <!-- 此处是相关代码 --> <ul class="nav nav-tabs" role="tablist"> </ul> <div class="tab-content" style="width:100%;"> </div> <!-- 相关代码结束 --> </div>
4. The usage method is as follows:
var item = {'id':'1','name':'菜单管理','url':'./menuctrl.html','closable':false}; closableTab.addTab(item);
Recommended: "bootstrap tutorial》
The above is the detailed content of How to close tab in bootstrap. For more information, please follow other related articles on the PHP Chinese website!

The reason for combining Bootstrap and React is their complementarity: 1. Bootstrap provides predefined styles and components to simplify UI design; 2. React improves efficiency and performance through component development and virtual DOM. Use it in conjunction to enjoy fast UI construction and complex interaction management.

Bootstrap is an open source front-end framework based on HTML, CSS and JavaScript, designed to help developers quickly build responsive websites. Its design philosophy is "mobile first", providing a wealth of predefined components and tools, such as grid systems, buttons, forms, navigation bars, etc., simplifying the front-end development process, improving development efficiency, and ensuring the responsiveness and consistency of the website. Using Bootstrap can start with a simple page and gradually add advanced components such as cards and modal boxes. Best practices for optimizing performance include customizing Bootstrap, using CDNs, and avoiding overuse of class names.

React and Bootstrap can be seamlessly integrated to enhance user interface design. 1) Install dependency package: npminstallbootstrapreact-bootstrap. 2) Import the CSS file: import'bootstrap/dist/css/bootstrap.min.css'. 3) Use Bootstrap components such as buttons and navigation bars. With this combination, developers can leverage React's flexibility and Bootstrap's style library to create a beautiful and efficient user interface.

The steps to integrate Bootstrap into a React project include: 1. Install the Bootstrap package, 2. Import the CSS file, 3. Use Bootstrap class name to style elements, 4. Use React-Bootstrap or reactstrap library to use Bootstrap's JavaScript components. This integration utilizes React's componentization and Bootstrap's style system to achieve efficient UI development.

Bootstrapisapowerfulframeworkthatsimplifiescreatingresponsive,mobile-firstwebsites.Itoffers:1)agridsystemforadaptablelayouts,2)pre-styledelementslikebuttonsandforms,and3)JavaScriptcomponentssuchascarouselsforenhancedinteractivity.

Bootstrap is a front-end framework developed by Twitter that integrates HTML, CSS and JavaScript to help developers quickly build responsive websites. Its core functions include: Grid system and layout: based on 12-column design, using flexbox layout, and supporting responsive pages of different device sizes. Components and styles: Provide a rich library of component, such as buttons, modal boxes, etc., and you can achieve beautiful effects by adding class names. How it works: Rely on CSS and JavaScript, CSS uses LESS or SASS preprocessors, and JavaScript relies on jQuery to achieve interactive and dynamic effects. Through these features, Bootstrap greatly improves development

BootstrapisafreeCSSframeworkthatsimplifieswebdevelopmentbyprovidingpre-styledcomponentsandJavaScriptplugins.It'sidealforcreatingresponsive,mobile-firstwebsites,offeringaflexiblegridsystemforlayoutsandasupportivecommunityforlearningandcustomization.

Bootstrapisafree,open-sourceCSSframeworkthathelpscreateresponsive,mobile-firstwebsites.1)Itoffersagridsystemforlayoutflexibility,2)includespre-styledcomponentsforquickdesign,and3)ishighlycustomizabletoavoidgenericlooks,butrequiresunderstandingCSStoop


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version
Chinese version, very easy to use

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
