These are all very basic and very simple. I wrote them down because I was afraid I could not remember them for a moment. Now I can take a look and consolidate my basic knowledge by the way.
The Code is as follows:
Var props = {
'For': 'htmlfor ',
'Class': 'classname ',
Readonly: 'readonly ',
Maxlength: 'maxlength ',
Cellspacing: 'cellspacing ',
Rowspan: 'rowspan ',
Colspan: 'colspan ',
Tabindex: 'tabindex ',
Usemap: 'usemap ',
Frameborder: 'frameborder'
}
When an object is created in json format, we recommend that you do not need single or double quotation marks for the attribute unless some keywords of ecmascript, such as the preceding 'for 'and 'class, we recommend that you use
Single quotation marks are not to say that single quotation marks must be better than double quotation marks and comply with specifications. However, it is very important to use single quotation marks instead of double quotation marks in the code.
A simple example:
The Code is as follows:
Name:
If you want to directly obtain an attribute value of a DOM element through access such as elem. propertyName, you must make a simple change to the preceding attribute access,
For example, in the above example, you want to get the label's for attribute value.
The Code is as follows:
Var ele = document. getElementById ('test ');
Var val = ele.html;
// Or
Val = ele ['html'];
// You do not need to perform special operations if you use standard DOM methods.
Val = ele. getAttribute ('');
Val = ele. getAttributeNode ('for '). value;
The above methods are also suitable for class and readonly access.
In my opinion, direct access through attributes may be faster than DOM access.
The following article will introduce the access to special attributes.