jQuery 通过将 Sizzle.js 与 jquery1.4.2 一起使用,我可以获得什么好处?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2762887/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 14:13:16  来源:igfitidea点击:

How and what benefit can I take by including Sizzle.js along with jquery1.4.2?

jquerycssxhtmlsizzle

提问by Jitendra Vyas

latest jquery 1.4.2 downloaded from jquery.com comes with Sizzle.js also.

从 jquery.com 下载的最新 jquery 1.4.2 也带有 Sizzle.js。

How and what benefit can I take from included Sizzle.js?

我可以从包含的 Sizzle.js 中获得什么好处?

Is Sizzle.js a standalone library?

Sizzle.js 是一个独立的库吗?

Why it's included inside jquery library, for what purpose?

为什么它包含在 jquery 库中,用于什么目的?

/*!
 * jQuery JavaScript Library v1.4.2
 * http://jquery.com/
 *
 * Copyright 2010, John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 * Copyright 2010, The Dojo Foundation
 * Released under the MIT, BSD, and GPL Licenses.
 *
 * Date: Sat Feb 13 22:33:48 2010 -0500
 */

while this is mentioned on sizzle.js website

虽然这是在 sizzle.js 网站上提到的

Completely standalone (no library dependencies)

完全独立(无库依赖项)

回答by Raul Agrait

Sizzle.jsis a JavaScript library that implements a "CSS selector engine designed to be easily dropped in to a host library." jQuery uses it internally for its CSS selection needs. If you wanted a CSS engine and had no need for all the other JavaScript benefits of jQuery, you could use Sizzle.js separately.

Sizzle.js是一个 JavaScript 库,它实现了“旨在轻松放入主机库的 CSS 选择器引擎”。jQuery 在内部使用它来满足其 CSS 选择需求。如果您想要一个 CSS 引擎并且不需要 jQuery 的所有其他 JavaScript 优势,您可以单独使用 Sizzle.js。

回答by Julian K

OK, it was actually pretty unclear what sizzle.js was to me. Basically, what it does is allows you to use javascript on 'selectors', that is, classes, IDs, DOM elements, etc... So when you use this in jQuery:

好吧,实际上我还不清楚 sizzle.js 对我来说是什么。基本上,它的作用是允许您在“选择器”上使用 javascript,即类、ID、DOM 元素等......所以当您在 jQuery 中使用它时:

$('div')

That's sizzle.js at work, making that element available to javascript.

这就是 sizzle.js 的作用,使该元素可用于 javascript。

I hope I got that all right :)

我希望我没问题:)

回答by Sarfraz

Here is the resource for that:

这是资源:

http://wiki.github.com/jeresig/sizzle/

http://wiki.github.com/jeresig/sizzle/

Selector Features

选择器功能

* CSS 3 Selector support
* Full Unicode support
* Escaped selector support #id\:value
* Contains text :contains(text)
* Complex :not :not(a#id)
* Multiple :not :not(div,p)
* Not attribute value [name!=value]
* Has selector :has(div)
* Position selectors :first, :last, :even, :odd, :gt, :lt, :eq
* Easy Form selectors :input, :text, :checkbox, :file, :password, :submit, etc
* Header selector :header

Code Features

代码特点

* Provides meaningful error messages for syntax problems
* Uses a single code path (no XPath)
* Uses no browser-sniffing
* Caja-compatible code

回答by Alex Sexton

jQuery requires sizzle in order to function. You can take the benefit of a working javascript library.

jQuery 需要嘶嘶声才能运行。您可以利用一个有效的 javascript 库。