A simple JavaScript library and demo

Source: Internet
Author: User

This auxiliary function library is an example of beginning JavaScript with Dom scripting and Ajax, but it is from the master of Christian Heilmann. I think it is worth learning from these new users.> Click here for download <

 

The following node refers to the document node, which is generally obtained through methods such as document. getelementsbytagname; TXT refers to the string;

Function

Parameter description

Init () Initialize this function library
Lastsibling (node) Obtain the last sibling of a node (not a text node)
Firstsibling (node) Obtain the first brother of a node.
Gettext (node) Get Text in A node
Settext (node, txt) Set the text in the node to txt
CreateLink (to, txt) Construct a <A> label whose href is to and whose text content is txt
Createtextelm (ELM, txt) Construct an elm tag whose text content is txt
Closestsibling (node, direction) Obtain the closest brother of a node. If ction is set to 1, it indicates the following brother. If it is set to-1, it indicates the previous brother.
Initdebug () Initialize the debugging environment
Setdebug (Bug) Show bug
Stopdebug () Stop debugging
Getkey () Obtain the key value
Gettarget (E) Obtain event targets
Stopbubble (E) Stop bubbling
Stopdefault (E) Stop default action
Cancelclick (E) Cancel
Addevent :( elm, evtype, FN, usecapture) Add an evtype event to Elm. The processing function is fn.
Cssjs (A, O, C1, C2) A can have four values: swap, add, remove, and check. O is the object, and c1 and c2 are the two CSS class names.
Safariclickfix () Fixed safari's explanation of stopdefault (E)

 

Here is a demo of applying this library in this book, which is also taken from this book.

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.