HIDE AND SHOW MODAL JQUERY


JS Modal (modal.js)

The Modal plugin is a dialog box/popup window that is displayed on top of the current page.

Bạn đang xem: Hide and show modal jquery

For a tutorial about Modals, read our Bootstrap Modal Tutorial.

The Modal Plugin Classes

Class Description .modal Creates a modal .modal-content Styles the modal properly with border, background-color, etc. Use this class to add the modal"s header, body, and footer. .modal-header Defines the style for the header of the modal .modal-toàn thân Defines the style for the body of the modal .modal-footer Defines the style for the footer in the modal. Note: This area is right-aligned by mặc định. To change this, overwrite CSS with text-align:left|center .modal-sm Specifies a small modal .modal-lg Specifies a large modal .fade Adds an animation/transition effect which fades the modal in & out

Trigger the Modal Via data-* Attributes

Add data-toggle="modal" and data-target="#modalID" to any element.

Xem thêm: Php Strstr() Function In Php, Php Strstr: How To Use Strstr() Function In Php

Note: For elements, omit data-target, & use href="#modalID" instead:


Example


Open Modal

mở cửa Modal


Modal Options

Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-backdrop="".

Name Type Default Description Try it backdrop boolean or the string "static" true Specifies whether the modal should have sầu a dark overlay: true - dark overlay false - no overlay (transparent)

If you specify the value "static", it is not possible to cthua trận the modal when clicking outside of it

Using JS Using data keyboard boolean true Specifies whether the modal can be closed with the escape key (Esc): true - the modal can be closed with Esc false - the modal cannot be closed with Esc Using JS Using data show boolean true Specifies whether lớn show the modal when initialized Using JS Using data

Modal Methods

The following table lists all available modal methods.

Method Description Try it .modal(options) Activates the nội dung as a modal. See options above sầu for valid values Try it .modal("toggle") Toggles the modal Try it .modal("show") Opens the modal Try it .modal("hide") Hides the modal Try it

Modal Events

The following table lists all available modal events.

Event Description Try it show.bs.modal Occurs when the modal is about khổng lồ be shown Try it shown.bs.modal Occurs when the modal is fully shown (after CSS transitions have sầu completed) Try it hide.bs.modal Occurs when the modal is about to lớn be hidden Try it hidden.bs.modal Occurs when the modal is fully hidden (after CSS transitions have sầu completed) Try it

More Examples

Login Modal

The following example creates a modal for login:


Example


 

Modal Login Example