Popover Plugin tutorial in Bootstrap CSS

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Popover Plugin Bootstrap CSS</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
        integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js"
        integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
        crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js"
        integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy"
        crossorigin="anonymous"></script>
    <script>
        $(function () {
            // $('[data-bs-toggle="popover"]').popover({
            //     html: true,
            //     title: "Popover title",
            //     content: "<h2>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Porro, omnis.</h2>"
            // });

            $("#showbtn").click(function () {
                $("#example").popover("toggle");
            });
            $("#hidebtn").click(function () {
                $("#example").popover("hide");
            });
            $("#example").on("show.bs.popover", function () {
                alert("Show");
            });
            $("#example").on("shown.bs.popover", function () {
                alert("Shown");
            });
            $("#example").on("hide.bs.popover", function () {
                alert("Hide");
            });
            $("#example").on("hidden.bs.popover", function () {
                alert("Hidden");
            });
            $("#example").on("inserted.bs.popover", function () {
                alert("Inserted");
            });

            const popover = new bootstrap.Popover(".example-popover", {
                container: ".modal-body"
            });

            // const popover = new bootstrap.Popover('.example-popover', {
            //     container: "body"
            // });
            // $("#example").popover({
            //     delay: { show: 1000, hide: 3000 }
            // });
        });
    </script>
</head>

<body>
    <!--How to make Website Layout with Bootstrap ?-->
    <!--3 Bootstrap CSS Classes : Container, Row, Col-->
    <!--When use "Col" Class ? Answer: For Equal Width Div Tag-->
    <!--Total width of Grid in Every row is 12-->
    <!--Col Class for different Break Points-->
    <!--Extra Large:col-lg, Large:col-lg, Medium:col-md, Small:col-sm, Extra Small-->
    <!--Total width of Column Grid must be maximum 12 in one Row-->
    <div class="container">
        <h2 class="py-3 text-center">Bootstrap Popover</h2>
        <div class="row py-5">
            <div class="col-md-7 mx-auto">
                <button id="example" class="btn btn-primary" data-bs-placement="bottom" data-bs-toggle="popover"
                    data-bs-title="Popover title" data-bs-html="true"
                    data-bs-content="<h2>Lorem ipsum dolor sit amet consectetur, adipisicing elit. Porro, omnis.</h2>">
                    Popover
                </button>
                <button class="btn btn-secondary" data-bs-placement="right" data-bs-toggle="popover"
                    data-bs-title="Popover title Two" data-bs-html="true"
                    data-bs-content="Lorem ipsum dolor sit <h5>amet consectetur</h5>, adipisicing elit. Nesciunt esse aut vel ex incidunt illum reiciendis eos quibusdam magni quod.">
                    Popover
                </button>
                <button id="showbtn" class="btn btn-danger" data-bs-toggle="popover" data-bs-html="true">
                    Show
                </button>
                <button id="hidebtn" class="btn btn-danger">
                    Hide
                </button>
                <span class="d-inlin-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus"
                    data-bs-content="Disabled popover">
                    <button class="btn btn-primary" type="button" disabled>Disabled Button</button>
                </span>
                <a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover"
                    data-bs-trigger="focus" data-bs-title="Dismissible popover"
                    data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible
                    popover</a>
                <button type="button" class="btn btn-secondary" data-bs-toggle="popover" data-bs-placement="right"
                    data-bs-custom-class="custom-popover" data-bs-title="Custom popover"
                    data-bs-content="This popover is themed via CSS variables.">
                    Custom popover
                </button>
                <script>
                    const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
                    const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
                </script>
            </div>
        </div>
    </div>
</body>

</html>










Comments

Popular posts from this blog

Badge Classes in Bootstrap CSS tutorial

Modal Plugin tutorial in Bootstrap CSS

Progress Bar Classes in Bootstrap CSS tutorial