Bootstrap JS Alert
การแจ้งเตือน JS (alert.js)
ปลั๊กอินการแจ้งเตือนมีตัวเลือกและวิธีการปิดข้อความแจ้งเตือน
สำหรับบทแนะนำเกี่ยวกับ Alerts โปรดอ่านBootstrap Alerts Tutorialของเรา
คลาสปลั๊กอินการแจ้งเตือน
Class | Description | Example |
---|---|---|
.alert | Creates an alert message box | |
.alert-danger | Red alert. Indicates a dangerous or potentially negative action | |
.alert-dismissible | Indicates a closable alert box. Together with the .close class, this class is used to close the alert (adds extra padding) |
|
.alert-info | Light-blue alert.Indicates a neutral informative change or action | |
.alert-link | Used on links inside alerts to provide matching colored links | |
.alert-success | Green alert. Indicates a successful or positive action | |
.alert-warning | Yellow alert. Indicates caution should be taken with this action | |
.close | Styles the close button for the alert message (floats right with a specified font-size, color, etc.) |
ปิดการแจ้งเตือนผ่าน data-* Attributes
เพิ่มdata-dismiss="alert"
ไปยังลิงก์หรือองค์ประกอบปุ่มเพื่อปิดข้อความแจ้งเตือน
ตัวอย่าง
<a href="#" class="close" data-dismiss="alert"
aria-label="close">×</a>
ปิดการแจ้งเตือนผ่าน JavaScript
ปิดด้วยตนเองด้วย:
ตัวอย่าง
$('.close').alert();
ตัวเลือกการแจ้งเตือน
None |
วิธีการแจ้งเตือน
ตารางต่อไปนี้แสดงรายการวิธีการเตือนที่มีทั้งหมด
Method | Description | Try it |
---|---|---|
.alert("close") | Closes the alert message |
แจ้งเตือนเหตุการณ์
ตารางต่อไปนี้แสดงเหตุการณ์การแจ้งเตือนที่มีทั้งหมด
Event | Description | Try it |
---|---|---|
close.bs.alert | Occurs when the alert message is about to be closed | |
closed.bs.alert | Occurs when the alert message has been closed |