Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Plugin reads options from element data $.fn.tooltip = function(defaults) { return this.each(function() { const opts = $.extend({}, defaults, $(this).data()); // opts.placement, opts.delay, opts.trigger from data attrs initTooltip(this, opts); }); }; // Usage in HTML — no extra JS needed // <button data-placement="top" data-delay="500">Hover me</button> $("[data-placement]").tooltip({ trigger: "hover" });
Result
Open