Instance
Add a small floating layer for any element to hold non-primary information.
The title of the PopOver and the length of the content are all 0 words will never be displayed.
Initialization
For performance reasons, ToolTips and popup data programming interfaces (data APIs) must be initialized manually .
The way to initialize all pop-up boxes on one page at once is by selecting the data-toggle property
<! DOCTYPE html>
<link href= "/stylesheets/bootstrap.min.css" rel= "stylesheet" >
<script src= "/scripts/jquery.min.js" ></script>
<script src= "/scripts/bootstrap.min.js" ></script>
<body>
<div class= "Container" style= "padding:100px 50px 10px;" >
<button type= "button" class= "btn Btn-default" title= "Popover title"
Data-container= "Body" data-toggle= "PopOver" data-placement= "left"
Data-content= "Some content in Popover on the left" >
Popover on the left
</button>
<button type= "button" class= "btn btn-primary" title= "Popover title"
Data-container= "Body" data-toggle= "PopOver" data-placement= "Top"
Data-content= "Some content in the top Popover" >
Top of the Popover
</button>
<button type= "button" class= "btn btn-success" title= "Popover title"
Data-container= "Body" data-toggle= "popover" data-placement= "Bottom"
Data-content= "Some content in the Popover at the bottom" >
Bottom of the Popover
</button>
<button type= "button" class= "btn btn-warning" title= "Popover title"
Data-container= "Body" data-toggle= "popover" data-placement= "right"
Data-content= "Some content in Popover on the right" >
Popover on the right
</button>
</div>
<script>$ (function ()
{$ ("[data-toggle= ' PopOver ']"). PopOver ();
});
</script>
</body>
1. UsageThrough JavaScript
Enable the popup box (PopOver) via JavaScript:
- $(' #example '). PopOver(options)
2. Parameters
Parameters can be passed through the Data property or JavaScript. For the Data property, attach the parameter name to data- , such as data-animation= "".
| Option Name |
type/Default value |
Data Property name |
Description |
| Animation |
Boolean Default value: True |
Data-animation |
Gives the popup a fade-out CSS animation effect. |
| Html |
Boolean Default value: False |
Data-html |
Inserts HTML into the popup box. If the text method is false,jquery, it will be used to insert content into the DOM. If you are concerned about XSS attacks, use text. |
| Placement |
String|function default value: Top |
Data-placement |
Specifies how to position the popover (that is, Top|bottom|left|right|auto). When auto is specified, the popup is dynamically adjusted. For example, if placement is "auto left", the pop-up box will appear on the right side as much as possible, and it will appear on the far side if the situation is not allowed. |
| Selector |
String Default value: False |
Data-selector |
If a selector is provided, the PopOver object is delegated to the specified target. |
| Title |
string | function default value: ' |
Data-title |
If the title property is not specified, the title option is the default title value. |
| trigger |
string Default value: ' Hover Focus ' |
data-trigger |
defines how the popup box is triggered: click| hover | focus | manual . You can pass multiple triggers, separated by a space between each trigger. |
| delay |
number | object Default value: 0 |
|
- delay< Span class= "pun" >:
- { Show: 500 Hide: 100
|
| Container |
string | False Default value: False |
Data-container |
Appends a popup box to the specified element. Example: container: ' Body ' |
3. Methods
Here are some useful methods in the pop-up box (Popover) Plugin:
| Method |
Description |
Example |
| options: . PopOver (Options) |
Attaches a popup handle to the collection of elements. |
- $(). popover(options)
|
| Toggle: . PopOver (' Toggle ') |
Toggles the pop-up of the show/hide element. |
- $(' #element '). PopOver(' Toggle ')
|
| Show: . PopOver (' show ') |
Displays the pop-up box for the element. |
- $(' #element '). PopOver(' show ')
|
| Hide: . PopOver (' hide ') |
The popup box for the hidden element. |
- $(' #element '). PopOver(' hide ')
|
| Destroy: . PopOver (' Destroy ') |
Hides and destroys the popup box for the element. |
- $(' #element '). PopOver(' Destroy ')
|
<! DOCTYPE html>
<link href= "/stylesheets/bootstrap.min.css" rel= "stylesheet" >
<script src= "/scripts/jquery.min.js" ></script>
<script src= "/scripts/bootstrap.min.js" ></script>
<body>
<div class= "Container" style= "padding:100px 50px 10px;" >
<button type= "button" class= "Btn btn-default popover-show"
title= "Popover title" data-container= "Body"
Data-toggle= "PopOver" data-placement= "left"
data-content= "Some content--show methods in the Popover on the left" >
Popover on the left
</button>
<button type= "button" class= "Btn btn-primary popover-hide"
title= "Popover title" data-container= "Body"
Data-toggle= "PopOver" data-placement= "Top"
data-content= "Some content--hide methods in the top Popover" >
Top of the Popover
</button>
<button type= "button" class= "Btn btn-success Popover-destroy"
title= "Popover title" data-container= "Body"
Data-toggle= "PopOver" data-placement= "Bottom"
data-content= "Some content--destroy methods at the bottom of Popover" >
Bottom of the Popover
</button>
<button type= "button" class= "Btn btn-warning popover-toggle"
title= "Popover title" data-container= "Body"
Data-toggle= "PopOver" data-placement= "right"
data-content= "Some content--toggle methods in the Popover on the right" >
Popover on the right
</button><br><br><br><br><br><br>
<p class= "Popover-options" >
<a href= "javascript:void (0);" type= "button" class= "btn btn-warning" title= "Data-container= "Body" data-toggle= "PopOver" data-content= "
Some content--options methods in Popover
</a>
</p>
<script>
$ (function () {$ ('. Popover-show '). PopOver (' Show ');});
$ (function () {$ ('. Popover-hide '). PopOver (' hide ');});
$ (function () {$ ('. Popover-destroy '). PopOver (' Destroy ');});
$ (function () {$ ('. Popover-toggle '). PopOver (' Toggle ');});
$ (function () {$ (". Popover-options a"). PopOver ({html:true});});
</script>
</div>
</body>
4. Events
The following table lists the events to use in the pop-up box (Popover) plugin.
| Events |
Description |
Example |
| show.bs.popover |
when call show The event is triggered immediately when the instance method is |
- $ ( ' #mypopover ' ( ' show.bs.popover ' , function () {
- //perform some actions ...
- })
|
| shown.bs.popover |
This event is triggered when the popup is visible to the user (will wait for the CSS transition to finish). |
- $ ( ' #mypopover ' ( ' shown.bs.popover ' , function () {
- //perform some actions ...
- })
|
| hide.bs.popover |
when calling Hide The event is triggered immediately when the instance method is |
- $ ( ' #mypopover ' ( ' hide.bs.popover ' , function () {
- //perform some actions ...
- })
|
| Hidden.bs.popover |
This event is triggered when a ToolTip is hidden from the user (will wait for the CSS transition effect to complete). |
- $(' #mypopover '). On(' hidden.bs.popover ', function () {
- //Perform some actions ...
- })
|
<! DOCTYPE html>
<link href= "/stylesheets/bootstrap.min.css" rel= "stylesheet" >
<script src= "/scripts/jquery.min.js" ></script>
<script src= "/scripts/bootstrap.min.js" ></script>
<body>
<div clas= "Container" style= "padding:100px 50px 10px;" >
<button type= "button" class= "Btn btn-primary popover-show"
title= "Popover title" data-container= "Body"
Data-toggle= "PopOver"
data-content= "Some content--show methods in the Popover on the left" >
Popover on the left
</button>
</div>
<script>
$ (function () {$ ('. Popover-show '). PopOver (' Show ');});
$ (function () {$ ('. Popover-show '). On (' Shown.bs.popover ', function () {
Alert ("warning message when displayed");
})});
</script>
</body>
Bootstrap-js (vi) Popup box