HTML attribute operation and precautions in JS base JS

Source: Internet
Author: User

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

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.