Bootstrap Tutorial JS Plugin pop-up learning notes sharing _javascript Tips

Source: Internet
Author: User
Tags button type

This article mainly to learn about JavaScript plug-ins-pop-up box.

Case

Add a small overlay to the content of the page, as it does on the ipad, adding additional information to the page elements.

Let's take a look at a few simple static case effects graphs

The effect is relatively simple mainly static pop-up small form, divided into form title and form content.

<div class= "Bs-example bs-example-popover" > <div class= "popover top" > <div class= "arrow" > &LT;/DIV&G

T 

But we still need to set a simple basic layout for the elements.

<style type= "Text/css" >

bs-example-popover. popover {position:relative; display:block; float:left;

width:240px; margin:20px;

}

</style>

Dynamic Demo

First look at the effect chart

A button, click on the button will pop up on the right side of the small form.

Look at the code, in fact, is also very simple.

[Code]<a id= "A2" class= "Btn btn-lg Btn-danger" right "data-placement=" that is to have short, fat, poor, ugly, data-content=, stay, The various kinds of shocking behavior and ideas that are characteristic of the character such as masturbate and contempt. Cock Silk (or writing "hanging silk") can be said by the curse words "cock dead", "hang", "Diao death" evolved. "Cock silk male" mainly refers to the poor family, such as the village or many cities at the bottom of the small citizen family, no more background, many junior high school is suspended, into the city, or become a restaurant waiter, or become an Internet Café network management, in the urban rich and sour in a cup of bitter soup, or otaku, jobless, but usually refused to admit, Individuals generally call themselves freelancers. "Title=" "href=" # "data-original-title=" the original meaning of "cock Silk" > "Click to toggle PopOver </a>[code]

Just a label for a, but gives the style class of the button, and then gives a couple of attributes, which are used primarily to show the pop-up box:

First:data-original-title--title

Second:data-content--content

Third:data-placement--position (top to bottom, bottom, left, right)

But now if you run, the button is there, you click on the button pop-up box will not appear, it is very simple, we have not yet initialized it, as in the previous section of the same ToolTip.

Just add a simple JavaScript code to it.

<script type= "Text/javascript" >

$ ("#a1"). PopOver ();

</script>

Four Directions

<div style= "margin-left:200px;margin-top:100px;margin-bottom:200px" class= "Bs-example Tooltip-demo" > < Div class= "Bs-example-tooltips" > <button type= "button" class= "btn Btn-default" data-container= "Body" Data-toggle= "PopOver" data-placement= "left" data-content= "Vivamus sagittis lacus vel the augue laoreet the Rutrum." > Left bomb frame </button> <button type= "button" class= "btn Btn-default" data-container= "Body" data-toggle= "PopOver" Data-placement= "Top" data-content= "Vivamus sagittis lacus vel augue laoreet rutrum faucibus." > Top frame </button> <button type= "button" class= "btn Btn-default" data-container= "Body" data-toggle= "PopOver" data-placement= "Bottom" data-content= "Vivamus sagittis lacus vel augue laoreet rutrum." > Bottom frame </button> <button type= "button" class= "btn Btn-default" data-container= "Body" data-toggle= "PopOver" Data-placement= "Right" data-content= "Vivamus sagittis lacus vel augue laoreet rutrum faucibus." > Right Bomb frame </butTon> </div> </div>

 

And then use JavaScript to activate it.

<script type= "Text/javascript" >

$ ("#a1"). PopOver ();

$ ("[Data-toggle=popover]"). PopOver ();

</script>

Features that are selectively added

For performance reasons, the Data property APIs for ToolTips and bullet box components are opt-in, meaning you have to initialize them yourself.

Pop-up boxes need additional settings when used in button groups and input box groups

When the prompt box is used in conjunction with. Btn-group or. Input-group, you need to specify the container: ' body ' option (see document below) to avoid unwanted side effects (for example, when the pop-up box is displayed, the page elements that work with it may become wider or rounded).

You need to add an extra element to wrap a pop-up box on a page element that you prohibit from using it

To add a pop-up box to a disabled or. Disabled element, wrap the page element that adds a pop-up box in a <div>, and then apply a pop-up box to the <div> element.

Usage
To enable pop-up boxes via javascript:

$ (' #example '). PopOver (Options)

Options

You can pass options through the Data property or JavaScript. For the Data property, the option name needs to be placed after data-, such as data-animation= "".

Method

$ (). PopOver (Options)

Initializes a pop-up box for a set of elements.

$ (' #element '). PopOver (' show ')

Displays a pop-up box.

$ (' #element '). PopOver (' hide ')

Hides the pop-up box.

$ (' #element '). PopOver (' toggle ')

Show or hide the pop-up box.

$ (' #element '). PopOver (' Destroy ')

Hide and destroy the pop-up box.

Event

$ (' [Data-toggle=popover] '). On (' Shown.bs.popover ', function () {

alert (1);

})

If you want to further study, you can click here to learn, and then attach 3 wonderful topics:

Bootstrap Learning Course

Bootstrap Practical Course

Bootstrap Plugin Usage Tutorial

The above is the entire content of this article, I hope to learn JavaScript program to help you.

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.