Bootstrap 4 บทช่วยสอน

BS4 HOME BS4 เริ่มต้น BS4 คอนเทนเนอร์ BS4 Grid Basic BS4 วิชาการพิมพ์ BS4 สี ตาราง BS4 BS4 รูปภาพ BS4 Jumbotron การแจ้งเตือน BS4 ปุ่ม BS4 กลุ่มปุ่ม BS4 ป้าย BS4 แถบความคืบหน้า BS4 BS4 Spinners BS4 การแบ่งหน้า BS4 รายการกลุ่ม การ์ด BS4 BS4 ดรอปดาวน์ BS4 ยุบ BS4 Navs BS4 Navbar แบบฟอร์ม BS4 อินพุต BS4 กลุ่มอินพุต BS4 BS4 แบบฟอร์มที่กำหนดเอง BS4 ม้าหมุน BS4 โมดอล เคล็ดลับเครื่องมือ BS4 BS4 ป๊อปโอเวอร์ BS4 ขนมปังปิ้ง BS4 Scrollspy BS4 ยูทิลิตี้ BS4 Flex ไอคอน BS4 วัตถุสื่อ BS4 ตัวกรอง BS4

Bootstrap 4 Grid

ระบบกริด BS4 BS4 ซ้อน/แนวนอน BS4 Grid XSmall BS4 กริดขนาดเล็ก BS4 กริดขนาดกลาง BS4 กริดขนาดใหญ่ BS4 Grid XLarge ตัวอย่างกริด BS4

Bootstrap 4 อื่นๆ

เทมเพลตพื้นฐาน BS4 แบบฝึกหัด BS4 แบบทดสอบ BS4

Bootstrap 4 อ้างอิง

ทุกชั้นเรียน JS Alert ปุ่ม JS JS Carousel JS ยุบ JS Dropdown JS Modal JS Popover JS Scrollspy JS แท็บ JS Toasts JS Tooltip


Bootstrap 4 JS Alert


คลาส CSS แจ้งเตือน

สำหรับบทแนะนำเกี่ยวกับ 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-dark Dark alert. Dark grey alert box
.alert-dismissible Indicates a closable alert box. Together with the .close class, this class is used to close the alert (adds extra padding)
.alert-heading Adds color:inherit to the specified element
.alert-info Light-blue alert.Indicates a neutral informative change or action
.alert-light Light alert. Light grey alert box
.alert-link Used on links inside alerts to provide matching colored links
.alert-primary Blue alert. Indicates an important action
.alert-secondary Grey alert. Indicates a "less" important action
.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">&times;</a>

ปิดการแจ้งเตือนผ่าน JavaScript

ปิดด้วยตนเองด้วย:

ตัวอย่าง

$('.close').alert("close");

ตัวเลือกการแจ้งเตือน

None

วิธีการแจ้งเตือน

ตารางต่อไปนี้แสดงรายการวิธีการเตือนที่มีทั้งหมด

Method Description Try it
.alert("close") Closes the alert message
.alert("dispose") Destroys an element's alert.

แจ้งเตือนเหตุการณ์

ตารางต่อไปนี้แสดงเหตุการณ์การแจ้งเตือนที่มีทั้งหมด

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 (will wait for CSS transitions to complete)