📅  最后修改于: 2020-10-21 08:42:46             🧑  作者: Mango
Prototype库带有许多预定义的对象和实用程序功能。您可以在JavaScript编程中直接使用这些函数和对象。
这些方法是有效的基于原型的JavaScript编码的基石之一。花一些时间研究它们以适应这些方法。
本章将通过示例详细介绍所有这些有用的方法。
S.No. | Method & Description |
---|---|
1. | $()
If provided with a string, returns the element in the document with matching ID; otherwise returns the passed element. |
2. | $$()
Takes an arbitrary number of CSS selectors (strings) and returns a document-order array of extended DOM elements that match any of them. |
3. | $A()
Converts the single argument it receives into an Array object. |
4. | $F()
Returns the value of a form control. This is a convenience alias of Form.Element.getValue. |
5. | $H()
Converts objects into enumerable Hash objects that resemble associative arrays. |
6. | $R()
Creates a new ObjectRange object. |
7. | $w()
Splits a string into an Array, treating all whitespace as delimiters. |
8. | Try.these
Accepts an arbitrary number of functions and returns the result of the first one that doesn’t throw an error. |
此方法检索(并扩展)所有CSS类名称为className的元素。
但是,此方法在最新版本的Prototype中已被弃用。