.livequery() 仅接收一个参数时如何工作?
How does .livequery() work when it only receives one parameter?
我正在访问 https://github.com/brandonaaron/livequery 试图找到 .livequery() 的语法。从我在官方文档中看到的,.livequery() 可以接收两个或三个参数:
// selector: the selector to match against
// matchedFn: the function to execute when a new element is added to the DOM that matches
$(...).livequery( selector, matchedFn );
// selector: the selector to match against
// matchedFn: the function to execute when a new element is added to the DOM that matches
// unmatchedFn: the function to execute when a previously matched element is removed from the DOM
$(...).livequery( selector, matchedFn, unmatchFn );
但是,在我检查的源代码中,我看到 .livequery() 只接收一个参数。例如:
$('.js-truncate').livequery(function() {
..................................
});
根据我的理解和我在官方文档中看到的,.livequery() 的第一个参数总是"selector"。当 .livequery() 接收到单个参数时,这是什么意思,在我的例子中是这个参数?:function(){.......}。谢谢。
现在对我来说无关紧要,因为从现在起我将使用 .on,因为我升级了 jQuery。
我正在访问 https://github.com/brandonaaron/livequery 试图找到 .livequery() 的语法。从我在官方文档中看到的,.livequery() 可以接收两个或三个参数:
// selector: the selector to match against
// matchedFn: the function to execute when a new element is added to the DOM that matches
$(...).livequery( selector, matchedFn );
// selector: the selector to match against
// matchedFn: the function to execute when a new element is added to the DOM that matches
// unmatchedFn: the function to execute when a previously matched element is removed from the DOM
$(...).livequery( selector, matchedFn, unmatchFn );
但是,在我检查的源代码中,我看到 .livequery() 只接收一个参数。例如:
$('.js-truncate').livequery(function() {
..................................
});
根据我的理解和我在官方文档中看到的,.livequery() 的第一个参数总是"selector"。当 .livequery() 接收到单个参数时,这是什么意思,在我的例子中是这个参数?:function(){.......}。谢谢。
现在对我来说无关紧要,因为从现在起我将使用 .on,因为我升级了 jQuery。