Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype Utility Methods


previous next AddThis Social Bookmark Button


Advertisements

The Prototype library comes with lot of predefined objects and utility functions. You can use those functions and objects directly in your JavaScript programming.

These methods are one of the cornerstones of efficient Prototype-based JavaScript coding. Spend some time with them to become comfortable.

This chapters detail all these useful methods with examples.

MethodDescription
$()If provided with a string, returns the element in the document with matching ID; otherwise returns the passed element.
$$()Takes an arbitrary number of CSS selectors (strings) and returns a document-order array of extended DOM elements that match any of them.
$A()Converts the single argument it receives into an Array object.
$F()Returns the value of a form control. This is a convenience alias of Form.Element.getValue.
$H()Converts objects into enumerable Hash objects that resemble associative arrays
$R()Creates a new ObjectRange object.
$w()Splits a string into an Array, treating all whitespace as delimiters.
Try.theseAccepts an arbitrary number of functions and returns the result of the first one that doesn't throw an error.

document.getElementsByClassName

This method retrieves (and extends) all the elements that have a CSS class name of className

However, this method has been deprecated in the latest versions of Prototype.



previous next Printer Friendly

Advertisements


  

Advertisements