============== about the display and hiding of elements =============
Visibility faster than display
There are 2 ways to create interesting effects by making pictures come and go: using the Visibility property of CSS or
Display property. For absolute position elements, diaplay and visibility have the same effect. The difference between the two is: set to
The Display:none element will no longer occupy the space of the document flow, while the element set to Visibility:hidden retains its original location.
============== a little experience =======================
1, JS variable does not have a block scope, in the judgement cycle in the definition of the entire function are defined
2. The parameter of Split () is a regular string, so if you use the Zhengze expression special character as a parameter, be sure to escape
============= in the browser when you move the mouse over the picture to jump out of the toolbar =============
Or
<meta http-equiv= "Imagetoolbar" content= "no" >
============= some tips ==================
1, #连接不会回到顶部
<a href= "#" ōnclick= "return false" >
---------------
2, close does not prompt
Opener=null;
Window.close ();
============js some summarization of object-oriented programming =============
1, static attribute class instance access is not, the same instance property can only be accessed by instance
var myfun=function () {this.a= "a"};
Myfun.b= "B";
Alert (new Myfun (). a);//Output A
alert (MYFUN.A);//Output undefined
alert (myfun.b);//Output B
Alert (new Myfun (). b);//Output undefined
2. Add attributes to Prototype
The properties that are added to the prototype will become common properties of the objects created using this constructor.
function Fish (name, color)
{
This.name=name;
This.color=color;
}
fish.prototype.livesin= "Water";
fish.prototype.price=20;
As the example above shows, each instance fish can have different names and colors, but they have a common attribute, which is that they all live in water.
This is because when an object is created, the constructor assigns its attribute prototype to the internal property __proto__ of the new object. This __proto__ is used by this object to find its properties.
3. Add function to object with prototype
Add a shared function to all objects by prototype. Here's a good thing: you don't have to create and initialize this function every time you construct an object.
4, each function has a static Name property (again, each built-in class has a static Name property), this property cannot and will not be overwritten
function A () ={};
var b=new Function ();
alert (b.name);//Output Anonymous
alert (a.name);//Output A
alert (array.name);//Output Array
================== about this==================
This is because he is not exactly equivalent to C + + or Java inside the this variable.
This is a method of prototype extension in JS that is closely attached to the calling location.
Like the above mentioned
MyObj.prototype.sayBye = function () {
Alert ("Bye" + this.name);
}
This inside of this, close to the prototype function is myobj (again note, JS class is implemented through the function), so this.name is the instance variable.
But in this case
MyObj.prototype.doSomething = function () {
Todo (function () {
alert (this.name);
});
}
This time, this represents the anonymous function
function () {
Alert (this.name)
}
Then there will be an error, and if you want to use this, you should use the auxiliary variable.
MyObj.prototype.doSomething = function () {
var me = this; Assign your own reference to the variable me
Todo (function () {
alert (Me.Name); To access the MyObj instance through me
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.