The basic effect question of jquery

Source: Internet
Author: User

jquery Second Assessment

The Gold

1. Noun interpretation

Instance object: var p1=new person (); P1 is the instance object

Construct: Function person () {}

Prototype objects: In JavaScript, when you define an object (the function is also an object), the object contains some predefined properties. Each of these function objects has an prototype attribute that points to the prototype object of the function . Add: Each object has a __proto__ property, but only the function object has the prototype Property

The relationship between prototype objects and constructs

By default, all prototype objects will automatically get a Constructor (constructor) property, this property (a pointer) that points to the prototype the function where the property resides ( Person )

Person.prototype.constructor = = Person

and the following relationship.

Person1.constructor = = Person

Prototype chains: Prototype objects are also simple objects and can have their own prototypes. If the prototype of a prototype object is a non-null reference, then so on, this is called the prototype chain.

2. Questions about the FirstChild

FirstChild: Returns the first child node of a node

Small tip: You need to consider compatibility issues: The following, can be compatible with the mainstream 5 major browsers

Order cannot be reversed

3. About node types

Interface

NodeType Constants

NodeType value

Note

Element

Node.element_node

1

ELEMENT node

Text

Node.text_node

3

Text node

Document

Node.document_node

9

Document

Comment

Node.comment_node

8

Text of the comment

DocumentFragment

Node.document_fragment_node

11

Document fragment

Attr

Node.attribute_node

2

Node properties

4. There is a UL label on the page, of which 3 li,html structures are as follows:

<ul id="Myul">

<li id="First"> Camel Xiangzi </li>

<li> lack of mind </li>

<li> Mouse Mat </li>

</ul>

Please add an Li node at the end of UL by JS Code

Var ul = document.getElementById ("ul");

Var li = document.createelement ("Li");

Ul.appendchild (LI);

5. Function AddNode () {

    1. 6. // get ul label
    2. 7. Var Ul=document.getelementbyid (' ul ');
    3. 8. // create an li tag
    4. 9. Var li=document.createelement (' Li ');
    5. // create an li text
    6. One. Var litext=document.createtextnode (' 005 ');
    7. Li.appendchild (Litext);
    8. Ul.appendchild (LI);
    9. 14.};
What is the advantage of jquery?

Small size, only about 100KB after compression

Powerful selector: Jquery 50% Selector

Excellent DOM encapsulation

Reliable event-handling mechanism

Excellent browser compatibility

Simplifying programming with implicit iterations

Rich plug-in support

$ (document). Ready () The difference from window.onload, standing in three dimensions to answer a question

Time to execute:$ (document). Ready: the DOM structure is executed when it is finished and does not have to wait until the load is complete. This means that the DOM tree is loaded and executed without having to wait until the page is loaded with pictures or other external files. And you can write multiple .ready.

window.onload: Is that all elements of the page are loaded, including all elements of the picture. Can only be performed once.

Number of writes: window. Onload: The same page can only be written one. The result can only be output once.

Ready: On the contrary!

Simplified code: $ (function () {});

There are three ways to set up the JQuery method in the form of JS and jquery:
    1. 1. set css properties
    2. $ (' div '). css (' height ', ' 30px ')
    3. $ ("div"). css ({fontSize: "30px", Color: "Red"})
    4. 2. using the attr method
    5. $ (' div '). attr (' height ', ' 30px ')
Js: The way to introduce styles one:

<script type= "Text/javascript" >

Alert (1);

</script>

Way two:

<script type= "Text/javascript" src= "Website.js" >

Alert (1);

</script>

Way three:

<a href= "javascript:void (0)" > Hot text </a>

<input type= "button" onclick= "JS function"/>

<input type= "button" onclick= "Javascript:alert (1)"/>

JS Setting Style:

Node.style.color = ' red ';

Node.classname = ' Teststyle ';

Element.style.cssText = ' height:100px!important ';

The list of jquery for the text values (form elements and non-form elements) is captured by the. js and jquery:

var lis = $ (' #first '). html ();

Alert (LIS); */

/* var INP = $ (' input '). Val ();

JS's:

Documentgetelementbyid (' id '). InnerHTML gets the contents of the text;

Documentgetelementbyid (' id '). Value gets the contents of the text box;

1. jquery objects and Dom objects are transferred to each other. The DOM object is converted to a JQuery object

For a DOM object, you just need to wrap the DOM object with $ () and you can get a JQuery object, $ (DOM object) Note: VAR is a variable defined

Such as:

2. JQuery objects into DOM objects

Two ways to convert a JQuery object into a DOM object: [index] and. get (index);

(1) JQuery object is a data object, you can get the corresponding DOM object by means of [index].

Such as:

var $V =$ ("#v");//jquery Object

var v= $v [0]//js Object

(2) JQuery itself provides, through the. Get (index) method to get the corresponding DOM object

Such as:

var $v =$ ("#v");//jquery Object

var v= $v. Get (0)//js Object

25. Hand-written wand effect, combining two major features of jquery: implicit iteration and chained programming//Two jquery light bar effect

/* $ ("li"). MouseOver (function () {

$ (this). CSS ("Background", "pink");

}). mouseout (function () {

$ (this). CSS ("Background", "");

}); */

26. Hierarchy Selector

Integer and int questions

int and integer

Difference:

1, integer is the wrapper class int, int is a basic data type of Java
2. The integer variable must be instantiated before it can be used, and the int variable does not need
3, the integer is actually a reference to the object, when new an integer, is actually generated a pointer to this object, and int is directly stored data values
4, the default value of integer is the default value of Null,int is 0

About the comparison of integers and int

1. Because the integer variable is actually a reference to an integer object, the two integer variables generated by new are never equal (because new generates two objects with different memory addresses).

2, integer variable and int variable comparison, as long as the value of two variables is equal, the result is true

(because the wrapper class integer and the base data type int are compared, Java is automatically wrapped to int and then compared, in fact it becomes a comparison of two int variables)

3. The result is false when the non-new generated integer variable is compared to the variable generated by the new Integer ().

(Because a non-new integer variable points to an object in a Java constant pool, the new Integer () generates a variable that points to the new object in the heap, and the address in memory is different)

4. For two non-new integer objects, when compared, if the value of two variables is between interval-128 to 127, the result of the comparison is true, if the value of the two variable is not in this interval, the comparison result is false

The difference between 14.Overload and override. Can the overloaded method change the type of the return value?

Overload is the meaning of overloading, override is the meaning of overrides, that is, rewriting.

Overloaded overload means that there can be more than one method with the same name in the same class, but the parameter lists of these methods vary (that is, the number of arguments or the type differs).

overriding override means that a method in a subclass can be exactly the same as the name and parameters of a method in the parent class, and invoking the method from an instance object created by the subclass invokes the definition method in the subclass, which is equivalent to overwriting the exact same method defined in the parent class. This is also a representation of the polymorphism of object-oriented programming. When a subclass overrides a method of a parent class, it can only throw fewer exceptions than the parent class, or a child exception that throws an exception thrown by the parent class, because subclasses can solve some problems with the parent class and cannot have more problems than the parent class. The subclass method can only be accessed more than the parent class, and cannot be smaller. If the method of the parent class is private, then the subclass does not have an override limit, which is equivalent to adding a new method to the subclass.

As to whether the overloaded method can change the type of return value, it depends on what you want to ask. The subject is very vague. If several overloaded methods have different parameter lists, their type of returnees can of course be different. But I guess the question you want to ask is: if the parameter list of the two methods is exactly the same, can you make them different from the return values to implement the overloaded overload. This is not possible, we can use contradiction to illustrate this problem, because we sometimes call a method can also not define the return result variable, that is, do not care about its return results, for example, when we call the Map.Remove (key) method, although the Remove method has a return value, However, we usually do not define a variable to receive the return result, when it is assumed that the class has two names and the parameter list is exactly the same method, only the return type is different, Java will not be able to determine the programmer's bottom is to invoke which method, because it can not be judged by the return result type.

Override can be translated as an overlay, literally knowing that it is covering a method and rewriting it to achieve different effects. The most familiar overlay for us is the implementation of the interface method, which is generally just a declaration of the method, and we need to implement all the methods of the interface declaration when we implement it. In addition to this typical usage, we may also overwrite methods in the parent class with the subclass in the inheritance. Be aware of the following points in the overlay:

1, the mark of the method of covering must match with the mark of the method that is covered completely, can reach the effect of coverage;

2. The return value of the overridden method must be the same as the return of the overridden method;

3. The exception that is thrown by the overridden method must be the same as the exception thrown by the overridden method, or its subclass;

4. The overridden method cannot be private, otherwise only a new method is defined in its subclass, and it is not overwritten.

Overload may be more familiar to us, can be translated as overloaded, it means that we can define some of the same name, by defining different input parameters to differentiate these methods, and then call, the VM will be based on different parameter styles, to choose the appropriate method of execution. The following points are to be noted in using overloading:

1. You can only pass different parameter styles when using overloads. For example, different parameter types, different number of parameters, different parameter order (of course, several parameter types within the same method must not be the same, such as can be Fun (int,float), but not fun (int,int));

2, can not be overloaded by access rights, return type, thrown exception;

3, the method of the exception type and number will not affect the overload;

4, for inheritance, if a method in the parent class is the access permission is PRIAVTE, then it can not be overloaded in the subclass, if defined, but also only defined a new method, but not to achieve the overloaded effect.

15. Say the Arraylist,vector,linkedlist storage performance and features
    1. ArrayList uses an array form to hold the object, which puts the object in a contiguous position, so the biggest drawback is that it is cumbersome to insert and delete.
    2. LinkedList takes objects in separate spaces and saves the next linked index in each space but the downside is that finding is very troublesome. To start with the first index
    3. Both ArrayList and vectors store data in arrays, where the number of elements is larger than the actual storage space for element additions and insertions, and they all allow the element to be indexed directly by ordinal, but inserting data elements involves memory operations such as element movement, so the index data is fast and the data is inserted slowly.
    4. Vectors use the Sychronized method (thread-safe), so the performance is worse than the ArrayList.
    5. LinkedList use a doubly linked list to store data, index data by ordinal need to traverse forward or backward data, so the index data is slow, is to insert data only need to record before and after items, so the speed of insertion.

ArrayList and the Vector the Difference ?
1). Synchronization: Vector is thread-safe, that is, synchronous, and ArrayList is thread insecure, not synchronous
2). Data growth: When growth is needed, vectors grow by default to the original, while ArrayList is half the original

16. Analyze the code, Number_two<<number and move the Number_two to the left 1 bits (the total number bit) is the same? What conditions are the same?

The basic effect question of jquery

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.