jQuery Top Sticky Notification Bar with topper.js

Code Snippet:Top notice bar
Author:
Published: January 19, 2024
Last Updated: January 22, 2024
Downloads: 4,921
License: MIT
Edit Code online: CodeHim
Read More

A lightweight jQuery plugin to create top sticky, close-able full width notification bar on the top of the page. The topper.js offers to show multiple types (success, warning, danger & info) notifications to the users.

How to Use Top Sticky Notification Bar :

1. Load the jQuery and Topper JS and CSS files into HTML document.

<!--jQuery 3.3.1-->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script>

<!--Topper Js-->
<script src="js/topper.js"></script>

<!--Topper CSS-->
<link rel="stylesheet" href="css/topper.css">

2. Create sticky notification bar on the top of page that will be disappear after the given time.

Topper({
  title: 'My Alert', //title for the alert message
  text: 'This is my sample info notification.', //the notification text
  style: 'info', //style of the notification
  type: 'top', 
  autoclose: 5000, //disappear after 5 seconds
});

All available styles are as follows:

  1. success
  2. info
  3. warning
  4. danger

3. If you would like to customize the plugin styles you can add your custom CSS. Just add the styles into topper-custom class.

.topper-custom{
   /* Your own css */
} 

Then add custom into style attribute.

Topper({
  title: 'My Alert',
  text: 'This is my custom styled notification.',
  style: 'custom',
  type: 'top',
  autoclose: false
});

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X