search
HomeWeb Front-endBootstrap TutorialDetailed explanation of the information prompt box in Bootstrap

This article will give you a detailed introduction to the information prompt box in Bootstrap. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Detailed explanation of the information prompt box in Bootstrap

The prompt box is a relatively common function. Generally speaking, when the mouse moves over a specific element, relevant prompts are displayed. [Related recommendations: "bootstrap Tutorial"]

Basic usage

The prompt box in the Bootstrap framework has a very simple structure and is often used. Create a button

1. Define the prompt information through the value of the title attribute (you can also use the custom attribute src-title to set the prompt information) , the title attribute has a high priority

2. Use the data-placement custom attribute to control the position of the prompt information box. According to four different positions, data-placement has four values: top, right, bottom and left, respectively indicating that the prompt box appears at the top, right, bottom and left

3. There is also the most important parameter that is indispensable, data-toggle="tooltip"

[Triggering method]

The triggering method of the prompt box in the Bootstrap framework is slightly different from the plug-in introduced earlier. It cannot be triggered directly through the custom attribute data-. Must rely on JavaScript code triggering

The simplest triggering method is as follows:

$(function(){
    $('[data-toggle="tooltip"]').tooltip();
});





<script>
$(function(){
    $(&amp;#39;[data-toggle=&quot;tooltip&quot;]&amp;#39;).tooltip();
});    
</script>

Detailed explanation of the information prompt box in Bootstrap

##Attribute parameters

The prompt box component provides 7 custom attribute parameters for setting the prompt box








<script>
$(function(){
    $(&amp;#39;[data-toggle=&quot;tooltip&quot;]&amp;#39;).tooltip();
});    
</script>

Detailed explanation of the information prompt box in Bootstrap

JS trigger

In addition to the simplest trigger method mentioned above, you can also specify an element separately, call the Tooltip component on the element, and provide various custom parameters in the form of javascript. There is no need to use element custom attributes starting with data-

$(element).tooltip(options);

<button type="button" class="btn btn-default" data-toggle="tooltip" >按钮</button>
<script>
$(function(){
    $(&#39;[data-toggle="tooltip"]&#39;).tooltip({
        title:"我是提示语",
        placement:&#39;right&#39;
    });
});    
</script>

Detailed explanation of the information prompt box in Bootstrap

[Keywords]

In addition to using the options object, you can also use keywords, 'show', 'hide', 'toggle', 'destroy'


<body style="margin-top:50px;">
<button type="button" class="btn btn-default" data-toggle="tooltip" title="提示信息" id="btn1">按钮1</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" title="提示信息"  id="btn2">按钮2</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" title="提示信息"  id="btn3">按钮3</button>
<button type="button" class="btn btn-default" data-toggle="tooltip" title="提示信息"  id="btn4">按钮4</button>
<script>
$(function(){
    $(&#39;#btn1&#39;).tooltip(&#39;show&#39;);//显示提示语
    $(&#39;#btn2&#39;).tooltip(&#39;hide&#39;);//关闭提示语
    $(&#39;#btn3&#39;).tooltip(&#39;toggle&#39;);//反转提示语
    $(&#39;#btn4&#39;).tooltip(&#39;destroy&#39;);//隐藏并销毁提示语
});    
</script>
</body>

Detailed explanation of the information prompt box in Bootstrap

【Event】

This plug-in supports 5 types of event subscriptions

show.bs.tooltip        show方法调用之后立即触发该事件
shown.bs.tooltip      此事件在tooltip已经显示出来(并且同时在 CSS 过渡效果完成)之后被触发
hide.bs.tooltip        hide方法调用之后立即触发该事件。
hidden.bs.tooltip     此事件在tooltip被隐藏(并且同时在 CSS 过渡效果完成)之后被触发
inserted.bs.tooltip    当tooltip模板加载到DOM中上时,在show.bs.tooltip触发后,触发该事件
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="right" title="提示信息" id="btn">按钮</button>
<script>
$(function(){
    $(&#39;#btn&#39;).tooltip();
    $("#btn").on("show.bs.tooltip",function(e){
        $(this).html(&#39;关闭提示&#39;);    
    }).on("hide.bs.tooltip",function(e){
        $(this).html(&#39;打开提示&#39;);
    })

});    
</script>

Detailed explanation of the information prompt box in Bootstrap##More programming related knowledge , please visit:

programming video

! !

The above is the detailed content of Detailed explanation of the information prompt box in Bootstrap. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:博客园. If there is any infringement, please contact admin@php.cn delete
Bootstrap: Frontend Development Made EasierBootstrap: Frontend Development Made EasierMay 02, 2025 am 12:10 AM

Bootstrap is an open source front-end framework that helps developers quickly build responsive websites. 1) It provides predefined styles and components such as grid systems and navigation bars. 2) Implement style and dynamic interaction through CSS and JavaScript files. 3) The basic usage is to introduce files and build pages with class names. 4) Advanced usage includes custom styles through Sass. 5) Frequently asked questions include style conflicts and JavaScript component issues, which can be solved through developer tools and modular management. 6) Performance optimization is recommended to selectively introduce modules and rationally use grid systems.

React and Bootstrap: The Ideal Combination?React and Bootstrap: The Ideal Combination?May 01, 2025 am 12:01 AM

React and Bootstrap are ideal combinations. 1) Use Bootstrap's CSS classes and JavaScript components, 2) integrate through React-Bootstrap or reactstrap, 3) load and optimize rendering performance on demand, and build an efficient and beautiful user interface.

Using Bootstrap: Creating Modern and Mobile-First WebsitesUsing Bootstrap: Creating Modern and Mobile-First WebsitesApr 30, 2025 am 12:08 AM

Bootstrap is an open source front-end framework for creating modern, responsive, and user-friendly websites. 1) It provides grid systems and predefined styles to simplify layout and development. 2) Mobile-first design ensures compatibility and performance. 3) Through custom styles and components, the website can be personalized. 4) Performance optimization and best practices include selective loading and responsive images. 5) Common errors such as layout problems and style conflicts can be resolved through debugging techniques.

Bootstrap and Web Design: Best Practices and TechniquesBootstrap and Web Design: Best Practices and TechniquesApr 29, 2025 am 12:15 AM

Bootstrap is an open source front-end framework developed by Twitter, suitable for building responsive websites quickly. 1) Its grid system is based on a 12-column structure, allowing for the creation of flexible layouts. 2) Responsive design function enables the website to adapt to different devices. 3) The basic usage includes building a navigation bar, and the advanced usage involves card components. 4) Common errors such as misuse of grid systems can be avoided by correctly setting the column width. 5) Performance optimization includes loading only necessary components, using CDN and file compression. 6) Best practices emphasize tidy code, custom styles and responsive design.

Bootstrap and React: Combining Frameworks for Web DevelopmentBootstrap and React: Combining Frameworks for Web DevelopmentApr 28, 2025 am 12:08 AM

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.

From Zero to Bootstrap: Getting Started QuicklyFrom Zero to Bootstrap: Getting Started QuicklyApr 27, 2025 am 12:07 AM

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: Enhancing User Interface DesignReact and Bootstrap: Enhancing User Interface DesignApr 26, 2025 am 12:18 AM

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.

Integrating Bootstrap into React: A Practical GuideIntegrating Bootstrap into React: A Practical GuideApr 25, 2025 am 12:04 AM

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.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.