Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
$.fn.tooltip = function(method) { const methods = { init() { this.on("mouseenter.tooltip", showTip) .on("mouseleave.tooltip", hideTip); }, destroy() { this.off(".tooltip") // remove namespaced events .removeData("tooltip") // clear plugin data .find(".tip").remove(); // remove injected DOM } }; return methods[method] ? methods[method].call(this) : methods.init.call(this); };
Result
Open