Prototype 1.6-utility mothed

Source: Internet
Author: User

Common prototype Methods

$ (), $ (), $ A (), $ F (), $ H (), $ R (), $ W ()

Try. These (), document. getelementsbyclassname ()

 

$ () Method

 

Syntax

$ (ID | element)-> htmlelement

$ (ID | element)...)-> [htmlelement...]

 

Description

If provided with a string, returns the element in the document with matching ID; Otherwise returns the passed element. takes in an arbitrary number of arguments. all elements returned by the function are extended with prototype Dom extensions.

 

Example

Function Foo (element ){

Element = $ (element );

}

$ () Method

Syntax

$ (Cssrule...)-> [htmlelement...]

Description

Takes an arbitrary number of CSS selectors (strings) and returns a document-order array of extended DOM elements that match any of them.

$ ('Div ')

//-> All divs in the document. Same as document. getelementsbytagname ('div ')!

$ ('# Contents ')

//-> Same as $ ('contents'), only it returns an array anyway.

$ ('Li. Faux ')

//-> All Li elements with class 'faux'

$ ('# Contents a [rel]')

//-> All links inside the element of ID "contents" with a rel attribute

$ ('A [href = "#"] ')

//-> All links with a href attribute of value "#" (eyeew !)

$ ('# Navbar li', '# sidebar li ')

//-> All links within the elements of ID "navbar" or "sidebar"

 

$ ()

$ A (iterable)-> actualarray

 

$ F () method

 

$ F (element)-> Value

<Body>

<Div id = "one" class = "foo"> single class name </div>

<Div id = "two" class = "foo bar Thud"> multiple class names </div>

<Ul id = "list">

<Li id = "item_one" class = "Thud"> list item 1 </LI>

<Li> list item 2 </LI>

<Li id = "item_two" class = "Thud"> list item 3 </LI>

</Ul>

</Body>

 

Document. getelementsbyclassname ('foo ');

//-> [Htmlelement, htmlelement] (div # One, div # Two)

Document. getelementsbyclassname ('thud ');

//-> [Htmlelement, htmlelement, htmlelement] (div # Two, Li # item_one, Li # item_two );

Document. getelementsbyclassname ('thud ', $ ('LIST '));

//-> [Htmlelement, htmlelement] (Li # item_one, Li # item_two)

 

 

Try. These () method

Gettransport: function (){

Return try. These (

Function () {return New XMLHttpRequest ()},

Function () {return New activexobject ('msxml2. xmlhttp ')},

Function () {return New activexobject ('Microsoft. xmlhttp ')}

) | False;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.