The Popover plugin works similarly to tooltips, appearing as a pop-up box when the user clicks on an element. The difference is that the popover can hold a lot more content.
Tip: Plugins can be added individually (via Bootstrap’s “popover.js” file) or all at once (“bootstrap.js” or “bootstrap.min.js”).
To create a popover, apply the data-toggle=”popover” property to an element.
The title attribute specifies the popover’s header text, while the data-content attribute specifies the text to be displayed inside the popover’s body:
Popovers must be initialized with jQuery by selecting the given element and calling the popover() method.
The code below will activate all popovers in the document:
By default, the popover appears on the right side of the element.
The data-placement attribute can be used to position the popover on the top, bottom, left, or right side of the element.
Tip: You can also use the data-placement attribute with the value “auto” to let the browser determine the position of the popover. For example, if the value is “auto left”, the popover will appear on the left side if possible, otherwise on the right.
When you click on the same element again, the popover is automatically closed. However, you can use the data-trigger=”focus” attribute to close the popover when clicking outside the element.
Tip: To display the popover when you move the mouse pointer over the element, use the data-trigger property with a value of “hover”:
CodingAsk.com is designed for learning and practice. Examples may be made simpler to aid understanding. Tutorials, references, and examples are regularly checked for mistakes, but we cannot guarantee complete accuracy. By using CodingAsk.com, you agree to our terms of use, cookie, and privacy policy.
Copyright 2010-2024 by Refsnes Data. All Rights Reserved.