Web page development, in many cases we need to manipulate the same class name elements, that is, class the same element. Yesterday to participate in the written exam, there is a related topic did not answer:
JavaScript Gets the node with class test in the page
Then collected a number of relevant data, in this article
(reader, person ); // Public method of subclass Reader. Prototype. getlike = Function (){ Return This . Like ;} // Instantiate subclass VaR Reader01 = New Reader ('books ', 'zj' ); Console. Log (reader01.getlike (); console. Log (reader01.getname ());
The key to 'classically inherited 'I understand is:
1. in the constructor of the subclass, call the constructor of the parent class (use
some basic terms!1. prototype)In fact, the prototype of an object is the prototype value of the constructor. All functions have a prototype attribute. When a function is created, it is automatically created and initialized, the initialization value is an object. This object comes with a constructor attribute, which refers to the constructor associated with the prototype.Function PeopleHope (money, house){This. money = money;This. house = house;}PeopleHope. prototype. hope = function () {documen
allow the next regular expression to continue to match. Because the above repetition is "greedy". In JavaScript regular expressions, you can repeat in a non greedy way, which is a feature of PERL5, but is implemented by JavaScript.Define a method that is not greedy: Simply add a question mark after the repeating character, for example:?? ,? +,? * even {1,5}? This is also possible.Examples are as follows:Normally,/a+/matches one or more character a, a
class in ES6 is equivalent to a constructor in es5, and if no constructor attribute is defined, an empty constructor is added by default;3,es5 , inheritance is a subclass that first creates its own instance object this, and then invokes the method of the parent class through Parent.call (this) or parent.apply (this);es6 , inheritance is The parent class first cr
This article focuses on parsing the javascript class inheritance mechanism, so that you can understand how javascript implements the concept of "inheritance" from the underlying layer. Currently, javascript implementation inheritance is not implemented through the "extend" keyword, but through the constructor function
definition, put the method outside using prototype to define. Solves the problem of the third method.
This method should actually be very friendly, but compared to Java syntax, there should be some disharmony, feel more messy, for C + +, we have less trouble feeling, but the development of C + + developers generally rarely involved in JavaScript, And for the developers of the Java EE, this approach is always somewhat awkward. The total feeling is not
Turn from: http://www.rainleaves.com/html/1684.html
A JavaScript static class is simply a class that does not have to be created by new, and can be used directly, like the built-in global class of JavaScript, such as math and object.
It is relatively simple to define and use objects in JavaScript, and you can define and initialize an object using {}.This definition of the object is an instance of the object class, which can dynamically add properties and methods during execution, which is very flexible. Let's look at an example:var obj = {property: "This is a parameter", Method:function () {return "This is a function, method is the func
All class members defined before the public members of the implementation class belong to the category of public members. any instance of the class openly discloses these attributes and methods. Private members of the implementation class are members that can be shared in the internal implementation of the
The class array object in JavaScript (Array-like object) refers to objects that look like arrays but are not arrays. The arguments variables and document.getElementsByTagName() return values in JavaScript are typical class array objects.Class Array attributes
The class
In JavaScript, a class has static and instance properties, as well as static and instance methods.Class Property (static property): Direct access through the class, without the need to declare an instance of the class to accessclass method (static method): Direct access through the
to the constructor associated with the prototype.Copy CodeThe code is as follows:function Peoplehope (money,house){This.money = money;This.house = House;}PeopleHope.prototype.hope = function () {document.write ("I want to have money, house");};/ /This is the prototype, which is initialized to the properties of the object by the constructor.For (var p in Peoplehope.prototype){document.write ("The prototype came out!") \ t "+ p +" }2. Simulation classIn fact, the "
Because most of the project JAVASCRIPT,CSS client work is another colleague in charge, the colleague and special busy can not be reconstructed, the boss also just make suggestions did not immediately implement refactoring. But I've also changed a little bit of client bugs in the last few days, it is true that the code is a little foggy, I do not know which mountain, easy to move code, so I started to tinker with the love and hate of
This article illustrates a simple right-click menu class for JavaScript implementations. Share to everyone for your reference. Specifically as follows:
This is your own write a right button menu class, shielding off the IE inherent right button menu, a total of four parameters: the first is to display the ID of the div of the right menu
The second is the right
This article will share with you the function of adding and removing javascript class names. For more information about how to add and remove javascript class names, see this article.
Method 1: Use the className attribute;
Method 2: Use the classList API;
// Function reg (name) {return new RegExp ('(^ | \ s)' + name +
functions: if you do not want to learn, it is to waste your youth.
My framework is designed to classify all functions using object-oriented thinking. For example, a function related to an array: makearray, as a member of the array class: array. Create (["AAA", "BBB"]); creates an array.
For an object-oriented JavaScript framework, you must solve the following problems:
Module mechanism-you must
Usually in the development process, accumulated a lot of experience and skills are applied to the project, and the next time you use it began to turn around. Sometimes also want to build a class library or toolkit to accumulate their own experience skills, and no special time to build a variety of environments, such as rollup or webpack such as packaging tools, ES6 transcoding tools Babel, Eslint, jest test tools and so on.Here is deliberately done a
The newly released JavaScript image switching effect achieves mosaic mask switching, which does not affect the "progress of human civilization ". In flash, it is very easy to implement the mask animation, but it is difficult to implement JavaScript.
Xmosaic. JS, like xscroll. js and xscroll2.jsLeafletThe javascript class
(targetName);};
A=document. CreateElement ("a");
}
With the above declaration, we can use the CreateElement class to create a DOM object in the Append function like C #.
Function
Copy Code code as follows:
function append (obj)
{
for (i=0;i{
var ele=new createelement ();
var a=ele.a;
a.title= "Hello";
a.href= "javascript:void (0);";
A.innerhtml=a.title;
A.click=function () {createdom ();};
$ (obj). appen
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.