AJAX-related JS code snippets and partial browser models

Source: Internet
Author: User

In. NET development, taking full advantage of free controls is a good thing, similarly, in PHP open, can use the Ajax class library is OK, but if you can not modify the control or class library to meet their own needs, it is necessary to use JS Dafa, the premise is to study the browser model of the various objects of the method properties. Especially familiar with css+html will do very cool. The JS language itself is not a high requirement.

1, dynamic Delete table inside content skills, do not need to write too much code, one line:

Tb.removenode (True) 3g.mlybyby.com

2, dynamic increase in line, in addition to the CreateElement method, can also be relatively short:

3. Dynamically add table in div

4, delete the table in the Div, simple as long as div.innerhtml= "" can.

The above is a few practical relatively short code, of course, there are other ways to achieve, but generally longer than the above, such as the combination of the use of Div object insertAdjacentHTML method, the use of different methods under different needs, the premise is to study the browser model of the various objects of the method properties. Especially familiar with css+html will do very cool. The JS language itself is not a high requirement.

Here is an example of the Document object, which is related to the following methods:

Method Description

Attachevent

CreateAttribute

Createcomment

Createdocumentfragment

CreateElement

Createeventobject

createStyleSheet

createTextNode

DetachEvent

getElementById

Getelementsbyname

getElementsByTagName

Mergeattributes

Recalc

Write

Writeln

In the case of Div objects, the relevant methods are:

Addbehavior

AppendChild

Applyelement

Attachevent

Clearattributes

CloneNode

Contains

DetachEvent

Getadjacenttext

GetAttribute

GetAttributeNode

getElementsByTagName

HasChildNodes

Insertadjacentelement

insertAdjacentHTML

insertAdjacentText

InsertBefore

Mergeattributes

Normalize

RemoveAttribute

RemoveAttributeNodewww.hrbnzyy.com

Removebehavior

RemoveChild

Removeexpression

RemoveNode

Replaceadjacenttext

ReplaceChild

ReplaceNode

SetActive

SetAttribute

Setattributenode

SetExpression

Other, such as drop-down list objects, and drag-and-drop operations I have time to collate and compare, to achieve the same function, relatively short of wonderful code is worth collecting.

RemoveNode (true) non-IE browser not supported, should be used Obj.parentNode.removeChild (obj); www.hrbnzyy120.com

InsertRow (x) InsertCell (y) This parameter is IE can be default, but in non-IE browser is not the default

As for Insertadjacentelement InnerText These are the unique methods of IE, not the standard, should be noted.

AJAX-related JS code snippets and partial browser models

Related Article

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.