Create Customizable Tooltips jQuery Plugin | jBox

jBox is a jQuery plugin that makes it easy to create customizable tooltips, modal windows, image galleries, and more or these plugins to implement a variety of popups on the webpage and the app.

With the jBox plugin, you can create:

  • Retractable conditional fund
  • Animated notification
  • Nice looking tip
  • A simplified view of the photo gallery

How to make use of it:

1. Include the jQuery library and the jBox plugin’s script & stylesheet in your doc.

<!-- Include jQuery -->
<script src="//"></script>

<!-- Include jBox -->
<link href="jBox.all.css" rel="stylesheet">
<script src="jBox.all.js"></script>

2. Create a tooltip for a component.

// Tooltip above and centered, this is the default setting

3. Create a default notification.

function demoNoticeDefault() {
  new jBox('Notice', {
    content: 'I\'m up here!'

4. Create a draggable modal window.

new jBox('Modal', {
  attach: $('#modalDragOnTitle'),
  width: 200,
  title: 'jBox',
  overlay: false,
  content: 'Drag me around by using the title',
  draggable: 'title',
  repositionOnOpen: false,
  repositionOnContent: false

5. Global choices.

// jBox ID
id: null,                    // Choose a unique id, otherwise jBox will set one for you (jBox1, jBox2, ...)

// Dimensions
width: 'auto',               // The width of the content area, e.g. 'auto', 200, '80%'
height: 'auto',              // The height of the content area
minWidth: null,              // Minimal width
minHeight: null,             // Minimal height
maxWidth: null,              // Maximal width
maxHeight: null,             // Maximal height

// Responsive dimensions
responsiveWidth: true,       // Adjusts the width to fit the viewport
responsiveHeight: true,      // Adjusts the height to fit the viewport
responsiveMinWidth: 100,     // Don't adjust width below this value (in pixel)
responsiveMinHeight: 100,    // Don't adjust height below this value (in pixel)

// Attach
attach: null,                // A jQuery selector to elements that will open and close your jBox, e.g. '.tooltip'
trigger: 'click',            // The event to open or close your jBox, use 'click', 'touchclick' or 'mouseenter'
preventDefault: false,       // Prevent the default event when opening jBox, e.g. don't follow the href in a link

// Content
content: null,               // You can use HTML or a jQuery element, e.g. jQuery('#jBox-content'). The elements will be appended to the content element and then made visible, so hide them with style="display: none" beforehand
getContent: null,            // Get the content from an attribute when jBox opens, e.g. getContent: 'data-content'. Use 'html' to get the attached elements HTML as content
title: null,                 // Adds a title to your jBox
getTitle: null,              // Get the title from an attribute when jBox opens, e.g. getTitle: 'data-title'
footer: null,                // Adds a footer to your jBox
isolate: true,         // Isolates scrolling to the content container

ajax: {                      // Setting an URL will make an AJAX request when jBox opens. Optional you can add any jQuery AJAX option (
  url: null,                 // The URL to send the AJAX request to
  data: '',                  // Data to send with your AJAX request, e.g. {id: 82, limit: 10}
  reload: false,             // Resend the AJAX request when jBox opens. Use true to send the AJAX request only once for every attached element or 'strict' to resend every time jBox opens
  getURL: 'data-url',        // The attribute in the source element where the AJAX request will look for the URL, e.g. data-url=""
  getData: 'data-ajax',      // The attribute in the source element where the AJAX request will look for the data, e.g. data-ajax="id=82&limit=10"
  setContent: true,          // Automatically set the response as new content when the AJAX request is finished
  loadingClass: true,        // Add a class to the wrapper when jBox is loading, set to class name or true to use the default class name 'jBox-loading'
  spinner: true,             // Hides the current content and adds a spinner while loading. You can pass HTML content to add your own spinner, e.g. spinner: '<div class="mySpinner"></div>'
  spinnerDelay: 300,         // Milliseconds to wait until spinner appears
  spinnerReposition: true    // Repositions jBox when the spinner is added or removed
cancelAjaxOnClose: true,     // Cancels the ajax call when jBox closes and it hasn't finished loading yet

// Position
target: null,                // The jQuery selector to the target element where jBox will be opened. If no element is found, jBox will use the attached element as target
position: {
  x: 'center',               // Horizontal position, use a number, 'left', 'right' or 'center'
  y: 'center'                // Vertical position, use a number, 'top', 'bottom' or 'center'
outside: null,               // Use 'x', 'y', or 'xy' to move your jBox outside of the target element
offset: 0,                   // Offset to final position, you can set different values for x and y with an object, e.g. {x: 20, y: 10}
attributes: {                // Note that attributes can only be 'left' or 'right' when using numbers for position, e.g. {x: 300, y: 20}
  x: 'left',                 // Horizontal position, use 'left' or 'right'
  y: 'top'                   // Vertical position, use 'top' or 'bottom'
fixed: false,                // Your jBox will stay on position when scrolling
adjustPosition: true,        // Adjusts your jBoxes position if there is not enough space, use 'flip', 'move' or true for both. This option overrides the reposition options
adjustTracker: false,        // By default jBox adjusts its position when it opens or when the window size changes, set to true to also adjust when scrolling
adjustDistance: 5,           // The minimal distance to the viewport edge while adjusting. Use an object to set different values, e.g. {top: 50, right: 5, bottom: 20, left: 5}
reposition: true,            // Calculates new position when the window-size changes
repositionOnOpen: true,      // Calculates new position each time jBox opens (rather than only when it opens the first time)
repositionOnContent: true,   // Calculates new position when the content changes with .setContent() or .setTitle()
holdPosition: true,          // Keeps current position if space permits. Applies only to 'Modal' type.

// Pointer
pointer: false,              // Your pointer will always point towards the target element, so the option outside needs to be 'x' or 'y'. By default the pointer is centered, set a position to move it to any side. You can also add an offset, e.g. 'left:30' or 'center:-20'
pointTo: 'target',           // Setting something else than 'target' will add a pointer even if there is no target element set or found. Use 'top', 'right', 'bottom' or 'left'

// Animations
fade: 180,                   // Fade duration in ms, set to 0 or false to disable
animation: null,             // Animation when opening or closing, use 'pulse', 'zoomIn', 'zoomOut', 'move', 'slide', 'flip', 'tada' (CSS inspired from Daniel Edens Animate.css:

// Appearance
theme: 'Default',            // Set a jBox theme class
addClass: null,              // Adds classes to the wrapper
overlay: false,              // Adds an overlay to hide page content when jBox opens (adjust color and opacity with CSS)
zIndex: 10000,               // Use a high z-index, or set to 'auto' to bring to front on open

// Delays
delayOpen: 0,                // Delay opening in ms. Note that the delay will be ignored if your jBox didn't finish closing
delayClose: 0,               // Delay closing in ms. Nnote that there is always a closing delay of at least 10ms to ensure jBox won't be closed when opening right away

// Closing
closeOnEsc: false,           // Close jBox when pressing [esc] key
closeOnClick: false,         // Close jBox with mouseclick. Use true (click anywhere), 'box' (click on jBox itself), 'overlay' (click on the overlay), 'body' (click anywhere but jBox)
closeOnMouseleave: false,    // Close jBox when the mouse leaves the jBox area or the area of the attached element
closeButton: false,          // Adds a close button to your jBox. Use 'title', 'box', 'overlay' or true (true will add the button to the overlay, title or the jBox itself, in that order if any of those elements can be found)

// Other options
appendTo: jQuery('body'),    // The element your jBox will be appended to. Any other element than jQuery('body') is only useful for fixed positions or when position values are numbers
createOnInit: false,         // Creates jBox and makes it available in DOM when it's being initialized, otherwise it will be created when it opens for the first time
blockScroll: false,          // Blocks scrolling when jBox is open
blockScrollAdjust: true,     // Adjust page elements to avoid content jumps when scrolling is blocked. See more here:
draggable: false,            // Make your jBox draggable (use 'true', 'title' or provide an element as handle) (inspired from Chris Coyiers CSS-Tricks
dragOver: true,              // When you have multiple draggable jBoxes, the one you select will always move over the other ones
autoClose: false,            // Time in ms when jBox will close automatically after it was opened
delayOnHover: false,         // Delay auto-closing while mouse is hovered
showCountdown: false,        // Display a nice progress-indicator when autoClose is enabled

// Audio                     // You can use the integrated audio function whenever you'd like to play an audio file, e.g. onInit: function () {'url_to_audio_file_without_file_extension', 75); }
preloadAudio: true,          // Preloads the audio files set in option audio. You can also preload other audio files, e.g. ['src_to_file.mp3', 'src_to_file.ogg']
audio: null,                 // The URL to an audio file to play when jBox opens. Set the URL without file extension, jBox will look for an .mp3 and .ogg file. To play audio when jBox closes, use an object, e.g. {open: 'src_to_audio1', close: 'src_to_audio2'}
volume: 100,                 // The volume in percent. To have different volumes for opening and closeing, use an object, e.g. {open: 75, close: 100}

// Events                    // Note that you can use 'this' in all event functions, it refers to your jBox object (e.g. onInit: function () {; })
onInit: null,                // Fired when jBox is initialized
onAttach: null,              // Fired when jBox attached itself to elements, the attached element will be passed as a parameter, e.g. onAttach: function (element) { element.css({color: 'red'}); }
onPosition: null,            // Fired when jBox is positioned
onCreated: null,             // Fired when jBox is created and availible in DOM
onOpen: null,                // Fired when jBox opens
onClose: null,               // Fired when jBox closes
onCloseComplete: null,       // Fired when jBox is completely closed (when fading is finished)
onDragStart: null,           // Fired when dragging starts
onDragEnd: null              // Fired when dragging finished

6. Default choices for the default plugins.

// Default options for tooltips
'Tooltip': {
  getContent: 'title',
  trigger: 'mouseenter',
  position: {
    x: 'center',
    y: 'top'
  outside: 'y',
  pointer: true

// Default options for mouse tooltips
'Mouse': {
  responsiveWidth: false,
  responsiveHeight: false,
  adjustPosition: 'flip',
  target: 'mouse',
  trigger: 'mouseenter',
  position: {
    x: 'right',
    y: 'bottom'
  outside: 'xy',
  offset: 5

// Default options for modal windows
'Modal': {
  target: jQuery(window),
  fixed: true,
  blockScroll: true,
  closeOnEsc: true,
  closeOnClick: 'overlay',
  closeButton: true,
  overlay: true,
  animation: 'zoomIn'

7. Default choices for the notice plugin.

new jBox('Notice', {
    color: null,      // Add a color to your notices, use 'gray' (default), 'black', 'red', 'green', 'blue' or 'yellow'
    stack: true,      // Set to false to disable notice-stacking
    stackSpacing: 10, // Spacing between notices when they stack
    autoClose: 6000,  // Time in ms after which the notice will disappear
    attributes: {     // Defines where the notice will pop up
      x: 'right',     // 'left' or 'right'
      y: 'top'        // 'top' or 'bottom'
    position: {       // Defines the distance to the viewport boundary
      x: 15,
      y: 15
    responsivePositions: {  // Responsive positions
      500: {                // The key defines the maximum width of the viewport, the values will replace the default position options
        x: 5,               // Start with the lowest viewport
        y: 5
      768: {
        x: 10,
        y: 10
    target: window,
    fixed: true,
    animation: 'zoomIn',
    closeOnClick: 'box',
    zIndex: 12000,

8. Default choices for the verify plugin.

new jBox('Confirm', {
    confirmButton: 'Submit',  // Text for the submit button
    cancelButton: 'Cancel',   // Text for the cancel button
    confirm: null,            // Function to execute when clicking the submit button. By default jBox will use the onclick or href attribute in that order if found
    cancel: null,             // Function to execute when clicking the cancel button
    closeOnConfirm: true,     // Close jBox when the user clicks the confirm button
    target: window,
    addClass: 'jBox-Modal',
    fixed: true,
    attach: '[data-confirm]',
    getContent: 'data-confirm',
    content: 'Do you really want to do this?',
    minWidth: 360,
    maxWidth: 500,
    blockScroll: true,
    closeOnEsc: true,
    closeOnClick: false,
    closeButton: false,
    overlay: true,
    animation: 'zoomIn',
    preventDefault: true,

9. Default choices for the picture plugin.

new jBox('Image', {
    src: 'href',                // The attribute where jBox gets the image source from, e.g. href="/path_to_image/image.jpg"
    gallery: 'data-jbox-image', // The attribute to set the galleries, e.g. data-jbox-image="gallery1"
    imageLabel: 'title',        // The attribute where jBox gets the image label from, e.g. title="My label"
    imageFade: 360,             // The fade duration for images in ms
    imageSize: 'contain',       // How to display the images. Use CSS background-position values, e.g. 'cover', 'contain', 'auto', 'initial', '50% 50%'
    imageCounter: false,        // Set to true to add an image counter, e.g. 4/20
    imageCounterSeparator: '/', // HTML to separate the current image number from all image numbers, e.g. '/' or ' of '
    target: window,
    attach: '[data-jbox-image]',
    fixed: true,
    blockScroll: true,
    closeOnEsc: true,
    closeOnClick: 'button',
    closeButton: true,
    overlay: true,
    animation: 'zoomIn',
    preventDefault: true,
    width: '100%',
    height: '100%',
    downloadButton: false,
    downloadButtonText: null,
    downloadButtonUrl: null,
    adjustDistance: {
      top: 40,
      right: 5,
      bottom: 40,
      left: 5

10. API strategies.

// opens the jBox;

// closes the jBox

// toggles the jBox

// sets the width

// sets the height

// sets the title

// sets the content

// attaches the jBox to elements
instance.attach(jQuery selector);

// removes the jBox from elements
instance.detach(jQuery selector);

// reloads the AJAX request

// plays an audio, volume);

// repositions the jBox

// animates the jBox
instance.animate(animation, options);

// disables the jBox

// enables the jBox

// hides the jBox

// shows the jBox;

// destroys the jBox

Versatile jQuery Popup Window Plugin, jBox Github

See Demo And Download

Official Website(StephanWagner): Click Here

This superior jQuery/javascript plugin is developed by StephanWagner. For extra Advanced Usages, please go to the official website.

Related Posts


How to Create a Simple Cookie Banner Consent Using Bootstrap 4

Cookie Consent Popup Javascript – Quick and simple tutorial for creating a simple Bootstrap cookie banner. If you have a website or blog with people visiting or…


Create Custom HTML Terminals With Pure JavaScript | shell.js

Custom HTML Terminals is A JavaScript library to create HTML terminals on web pages. The shell js JavaScript library offers a straightforward method to create Ubuntu, OS X,…


Bootstrap Alert, Confirm, and Flexible Dialog Boxes | Bootbox

Bootbox.js is a small JavaScript library that allows you to create programming dialogs using Bootstrap templates, without having to worry about creating, managing, or removing any required…


An Accessible Touch-enabled Slider Web Component | fg-carousel

fg-carousel Slider – A simple & modern slider web component to create versatile, accessible, touch-enabled picture carousels utilizing CSS scroll snap, Custom Element, and Intersection Observer API….


A Lightweight and Efficient Tags Input Component in Vanilla JS | tagify

tagify transforms an input field or textarea into a tags component, in an easy and customizable way, with great performance and a small code footprint, full of…


A Lightweight Library to Copy Text to Clipboard | CopyJS

CopyJS is a lightweight JavaScript library that allows you to copy plain text or HTML content to the clipboard. Must Read: Tiny Library for Copy Text In…