我正在处理以下Click Outside功能
$(function () {
jQuery.fn.clickoutside = function (callback) {
var outside = 1, self = $(this);
self.cb = callback;
this.click(function () {
outside = 0;
});
$(document).click(function () {
outside && self.cb();
outside = 1;
});
return $(this);
}
});
我正在使用它:
$("nav.menu").clickoutside(function (e) {
// Do something
});
但是如何转换我的代码以将其用作事件。类似的东西:
$("nav.menu").on("click:outside", function (e) {
// Do something
});