gpt4 book ai didi

javascript - jQuery:live ('focus' ) 和 live ('blur' ) 嵌套在命名空间中,在 1.3.2 中不起作用

转载 作者:行者123 更新时间:2023-11-29 17:30:45 25 4
gpt4 key购买 nike

我有以下html

<input class="hasToolTip" type="text" value="meh"/>
<span class="tooltip" style="display: none;">tooltip here</span>

我希望工具提示在输入获得焦点时淡入,所以我使用正确的方法创建了一个 namespace (它包含我所有用于输入/表单的 javascript,如下所示)

var inputCommon = (function() {
return {
SetupToolTips: function() {
$(".hasToolTip").live('focus', function() {
$(this).next(".tooltip").fadeIn();
});
$(".hasToolTip").live('blur', function() {
$(this).next(".tooltip").fadeOut();
});
}
};

})();

然后我在加载文档时调用它

$(function() {
inputCommon.SetupToolTips();
});

还有... it doesn't work with jQuery 1.3.2 . It works with 1.4.2虽然,但我现在真的准备好插入图书馆的改变。

知道我怎样才能吃到我的蛋糕(命名空间!)并吃掉它(现场工作!)吗?


没有人会拒绝自欺欺人,这是我跳过的明确摘录,straight from the horse's mouth :

In jQuery 1.3.x only the following JavaScript events (in addition to custom events) could be bound with .live(): click, dblclick, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, and mouseup.

(...)

As of jQuery 1.4.1 even focus and blur work with live (mapping to the more appropriate, bubbling, events focusin and focusout).

最佳答案

如果没有一些严重的变化,你真的不能这样做,这些变化可能会引入比升级到 1.4+ 还要多的问题。事件系统在 1.4.2 中进行了大修,并从那时起进一步完善......你的时间花在升级到 jQuery 1.4+ 上比尝试将对此支持到 1.3.x 上要好得多。

关于javascript - jQuery:live ('focus' ) 和 live ('blur' ) 嵌套在命名空间中,在 1.3.2 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4398952/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com