Bootstrap introduction (29) JS plugin 6: Popup box

Source: Internet
Author: User

Bootstrap introduction (29) JS plugin 6: Popup box

Add small coverage content, like on ipad, for storing non-primary information

The popup is dependent on the ToolTip plug-in, and it is the same as the ToolTip, which needs to be initialized before it can be used.

First we introduce CSS files and JS files

        <href= "Bootstrap.min.css"  rel= "stylesheet">
        <src= "jquery-3.1.0.min.js"  type= "Text/javascript"> </script>        <src= "Bootstrap.min.js"  type= "Text/javascript"></script>

Let's start by creating a few buttons to trigger

        <Divclass= "Container">            <Buttontype= "button"class= "btn btn-default js-popover"Data-toggle= "PopOver"data-placement= "Bottom"title= "title"data-content= "Content">Pop-up Box 1</Button>        </Div>

His use also requires us to add JS code (Initialize)

(Note that the index here is in class)

        < Script >             $ (". Js-popover"). PopOver ();         </ Script >

Open the page, click the button

We also have another direction, as long as the data-placement= "bottom" inside the bottom changed to left, right, top on it (the default is the side)

In this case, click the button to appear, click the button disappears, sometimes we want to press the blank space to let it disappear what to do?

Just add a new property to the button's properties data-trigger= "Focus" is OK.

        <Divclass= "Container">            <Buttontype= "button"class= "btn btn-default js-popover"Data-toggle= "PopOver"data-placement= "Bottom"title= "title"data-content= "Content"Data-trigger= "Focus">Pop-up Box 1</Button>        </Div>

Refresh the page, click the button, the content appears, click on the blank, disappear.

In fact this is the default has an over-effect, if we want the qualifying effect disappears (that is, suddenly pop suddenly disappear), you can continue to add the property data-animation= "false" can be

Sometimes we want to show up when the page is displayed, you can modify the JS code

        < Script >             $ (". Js-popover"). PopOver ('show') );         </ Script >

Like other JS plugins, he has four situations, appearing before, appearing, hiding before, hiding after

Try the simplest pop-up cue box, which is hidden after

Modify JS Code

        <Script>            $(". Js-popover"). On ("Hidden.bs.popover",function(e) {alert ("Hello");        }); </Script>

Refresh the page, click the button, let the popup box disappear after the prompt hello

Bootstrap introduction (29) JS plugin 6: Popup box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.