Home >
Web Front-end >
JS Tutorial >
Sharing of 7 different syntaxes in JavaScript between IE and Firefox_javascript skills
Sharing of 7 different syntaxes in JavaScript between IE and Firefox_javascript skills
WBOY
Release: 2016-05-16 17:59:58
Original
1109 people have browsed it
In this article, the author introduces 7 different JavaScript syntaxes in IE and Firefox.
1. CSS "float" value
The most basic syntax for accessing a given CSS value is: object.style.property, using camelCase to replace the value with connectors , for example, to access the background-color value of a
with the ID "header", we use the following syntax:
2. The estimated style of the element JavaScript can use the object.style.property syntax to easily access and modify a CSS style externally, but the limitation is that these syntaxes can only take out already set inline styles or styles set directly by JavaScript. It cannot access an external style sheet. To access the "imputed" style of an element we can use the following code:
var myObject = document.getElementById( "header"); var myComputedStyle = document.defaultView.getComputedStyle(myObject, null); var myStyle = myComputedStyle.backgroundColor;
3. Access the element's "class" Like "float", "class" is a reserved word of JavaScript. In these two browsers, we use the following syntax to access "class".
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn