Question: How to get the content of CSS directly
Give a few examples to test first: first define a CSS file
#div2 {
width:500px;
height:200px;
Background-color:green;
left:50px; top:200px; Position:absolute;
}
#div3 {
width:500px;
height:200px;
background-color:red;
left:50px; top:450px; Position:absolute;
}
Define an HTML file again
Through the above code test, found that you can not directly get the attributes in the CSS, the problem first put
JS-oriented (based on) object programming----construction Method (function)
Introduction to construction methods (functions)
Basic usage of constructors
function class name (argument list) {
property = parameter value;
}
Examples are as follows:
Extension: Can pass directly to an object a function.
Please see the following question:
When you initialize a property value to an object, you can also specify the function property
See Case:
Construct method (function) Summary constructor method name and class name the same primary role is to complete initialization of a new object instance when an object instance is created, the system automatically invokes the method of constructing the object
Here we further refine the definition of the class:
further understanding of object-oriented programming
create another form of an object:If an object is simpler, we can create it directly (you can specify normal properties and function properties)
Sometimes we see such a calling method
The name of the function. Call (object instance)
So called, the function's this is pointing to an object instance
Use for ... in to easily view all properties and methods of an object
The most important thing here is the properties and methods of the browser window object, using for in We can know which methods and properties in the Browser Support window object We are currently using, so we don't have to look up the network, there are other objects in the browser in addition to Window objects, as shown in the following illustration:
View the properties and methods of the browser window object in the following ways: (I use Firefox browser)
Loops list all properties and methods of the Window object
Document.writeln ("* * * Current browser Window object has properties and methods ***<br/>");
for (var key in window) {
Document.writeln (key + ":" + Window[key] + "<br/>");
}
Output results:
Then look at the browser history object properties and methods: (I use the Firefox browser)