遅延のある関数を作ろうとしています。段落をクリックすると、この段落の前にMENUが追加されます。しかし、いつでも、または遅れてメニューを非表示にする必要があります。mouseleave
mouseout
例を次に示します: http://jsfiddle.net/yinternet/bZLAv/
HTML
<p class="add_to_this1">Click here 1</p>
<p class="add_to_this2">Click here 2</p>
<p class="add_to_this3">Click here 3</p>
<div id="menu"> I'm here</div>
jQuery
jQuery.fn.handler = function () {
$(this).on({
click: function(e) {
if ($(this).find("#menu").length) {
return;
}
$('#menu').prependTo($(this));
$("#menu").css({
position: "absolute",
left: "100px"
}).show();
}
});
}
$(".add_to_this1").handler();
$(".add_to_this2").handler();
$(".add_to_this3").handler();