3
我有以下的jQuery代碼,試圖實現對event.`jQuery的mouseon /鼠標移開或內徘徊「開」綁定事件
$(".editable_template_region").on({"mouseover":function(){
$('<a href="javascript:void(0)" class="hoverItTemplate">click to edit</a>').appendTo($(this));
}, "mouseout" : function() {
$(this).find(".hoverItTemplate").remove();
}});`
我的綁定與時不工作很正確不要認爲這段代碼是正確的,因爲這會導致事件「閃爍」或反覆循環。所以我的懸停課只是閃爍着。
這是我以前使用過的代碼,但我想將它切換到on事件以獲得更好的綁定。
$(".editable_template_region").hover(function() {
$('<a href="javascript:void(0)" class="hoverItTemplate">click to edit</a>').appendTo($(this));
}, function() {
$(this).find(".hoverItTemplate").remove();
});
在此先感謝。
這按預期工作。謝謝你的例子。 –