The HTML attribute operation in JS
HTML attribute manipulation: Read and write;
Property Read operation: function: Get, find;
Syntax: element. Property name
Attribute write operation: function: replace, modify;
Syntax: element. property name = new Value---> is replaced.
InnerHTML: Reads all HTML content within the element;
Syntax: element. innerhtml;//Reading HTML content
Syntax: element. InnerHTML = new value;//Modify HTML inside
Capacity
/* attribute read/write operation precautions */
"-" is not allowed in 1.JS
Example: ODiv.style.fontSize
Remove the "-" in Font-size and capitalize the first letter of size;
such as: Padding-top ====> paddingtop;
If you want to change the class name in 2.JS, you need to write:
Odiv.classname = ' new name ';
Class is a reserved word and cannot be written directly.
3. All the * * Relative path * *, do not take to make judgments;
such as: IMG SRC
href= "1.css"
Color values do not make judgments:
color:red #foo RGB (250,0,0)//indeterminate value;
InnerHTML value do not take to make judgments;
4. Modify the type value of the form element:
IE6 IE7 IE8 compatibility problem, solve the idea: try to bypass direct repair
Change the type value in the form element to achieve visual effect.
Compatibility issues with 5.float:
It is best to write the left and right floating in the CSS, where to float, to add the corresponding class to the tag. So IE and other browsers are compatible;
HTML attribute operation and precautions in JS base JS