mootools 选择器_MooTools中的Sizzle和Peppy选择器引擎
mootools 選擇器
A few weeks back I touched on how you could implement the Peppy and Sizzle selector engines in MooTools. Both posts showed how to remove the default Moo engine from use and instead make each respective selector engine the one and only. It doesn't have to be that way. You could use all three engines within the page as well.
幾周前,我談到了如何在MooTools中實現Peppy和Sizzle選擇器引擎。 這兩篇文章都展示了如何從使用中刪除默認的Moo引擎,而是使每個選擇器引擎成為唯一的選擇器引擎。 不一定要那樣。 您也可以在頁面中使用所有三個引擎。
Peppy,Sizzle和Moo在一起 (Peppy, Sizzle, and Moo Together)
//assuming that the JavaScript files we brought in via simple XHTML above.../* MooTools */ var divs = $$('div');/* Sizzle */ Window.$Sizzle = function(selector){return new Elements(new Sizzle(selector)); } //sizzle usage var divs = $Sizzle('div');/* Peppy */ Window.$Peppy = function(selector){return new Elements(new peppy.query(selector)); } //Peppy usage var divs = $Peppy('div');Why do this? Each engine has its advantages. Sizzle generally does better with Internet Explorer so if you detect that the user is using IE, you may want to use Sizzle to grab the elements instead.
為什么這樣 每個引擎都有其優勢。 Sizzle通常在Internet Explorer上做得更好,因此,如果您檢測到用戶正在使用IE,則可能要使用Sizzle來獲取元素。
In most cases the overhead of bringing in each engine makes this strategy overkill. It's definitely an option though.
在大多數情況下,引入每個引擎的開銷使該策略變得過大。 當然,這絕對是一個選擇。
翻譯自: https://davidwalsh.name/mootools-peppy-sizzle
mootools 選擇器
總結
以上是生活随笔為你收集整理的mootools 选择器_MooTools中的Sizzle和Peppy选择器引擎的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 硬件保护和软件保护_什么是硬件保护?
- 下一篇: 008-2018-09-12 文件操作